diff options
Diffstat (limited to 'stdlib/source/library/lux/target/ruby.lux')
-rw-r--r-- | stdlib/source/library/lux/target/ruby.lux | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index eb0f542ac..3280ac134 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -221,18 +221,30 @@ (format content \n+ "end" ..statement_suffix)) - (def: .public (apply/* arguments block_lambda func) - (-> (List Expression) (Maybe Expression) Expression Computation) + (type: .public Block + [(List LVar) + Statement]) + + (def: .public (apply/* arguments block func) + (-> (List Expression) (Maybe Block) Expression Computation) (let [arguments (|> arguments (list#each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed ["(" ")"])) - block (case block_lambda + block (case block {.#None} "" - {.#Some lambda} - (format " &" (:representation lambda)))] + {.#Some [inputs block]} + (|> block + :representation + nested + control_structure + (format " do " + (|> inputs + (list#each (|>> :representation)) + (text.interposed ..input_separator) + (text.enclosed' "|")))))] (:abstraction (format (:representation func) arguments block)))) (def: .public (the field object) @@ -413,6 +425,7 @@ (:abstraction (format "(" <unary> (:representation subject) ")")))] ["!" not] + ["~" bit_not] ["-" opposite] ) @@ -420,11 +433,24 @@ (All (_ brand) (-> Text (Code brand) (Code brand))) (:abstraction (format "# " (..safe commentary) \n+ (:representation on)))) + + (def: .public (class name definition) + (-> LVar Statement Statement) + (:abstraction + (format "class " (:representation name) + (control_structure + (nested + (:representation definition)))))) + + (def: .public (attribute_readers attributes) + (-> (List Text) Statement) + (..statement + (..apply/* (list#each ..string attributes) {.#None} (..local "attr_reader")))) ) -(def: .public (do method arguments block_lambda object) - (-> Text (List Expression) (Maybe Expression) Expression Computation) - (|> object (..the method) (..apply/* arguments block_lambda))) +(def: .public (do method arguments block object) + (-> Text (List Expression) (Maybe Block) Expression Computation) + (|> object (..the method) (..apply/* arguments block))) (def: .public (apply_lambda/* args lambda) (-> (List Expression) Expression Computation) |