Class: ComponentEmbeddedRuby::Compiler
- Inherits:
-
Object
- Object
- ComponentEmbeddedRuby::Compiler
- Defined in:
- lib/component_embedded_ruby/compiler.rb
Instance Method Summary collapse
-
#initialize(nodes, output_var_name: "__crb_out", skip_return: false, safe_append_method: "<<", unsafe_append_method: "<<") ⇒ Compiler
constructor
A new instance of Compiler.
- #to_ruby ⇒ Object
Constructor Details
#initialize(nodes, output_var_name: "__crb_out", skip_return: false, safe_append_method: "<<", unsafe_append_method: "<<") ⇒ Compiler
Returns a new instance of Compiler.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/component_embedded_ruby/compiler.rb', line 5 def initialize( nodes, output_var_name: "__crb_out", skip_return: false, safe_append_method: "<<", unsafe_append_method: "<<" ) @nodes = Array(nodes) @functions = {} @output_var_name = output_var_name @skip_return = skip_return @safe_append_method = safe_append_method @unsafe_append_method = unsafe_append_method end |
Instance Method Details
#to_ruby ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/component_embedded_ruby/compiler.rb', line 20 def to_ruby <<~RUBY #{output_var_name} ||= ''; #{nodes.map(&method(:render)).join("\n")} #{output_var_name unless @skip_return}; RUBY end |