Class: Yadriggy::StringInterpolation
- Includes:
- AstHelper
- Defined in:
- lib/yadriggy/ast.rb
Overview
String interpolation.
Instance Attribute Summary collapse
-
#contents ⇒ Array<ASTnode>
readonly
The strings and the embedded expressions.
Attributes inherited from ASTnode
Class Method Summary collapse
Instance Method Summary collapse
-
#accept(evaluator) ⇒ void
A method for Visitor pattern.
-
#initialize(sexp) ⇒ StringInterpolation
constructor
A new instance of StringInterpolation.
Methods included from AstHelper
#has_tag?, #to_node, #to_nodes
Methods inherited from ASTnode
#add_child, #add_children, #const_value, #const_value_in_class, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string, #value, #value_in_class
Constructor Details
#initialize(sexp) ⇒ StringInterpolation
Returns a new instance of StringInterpolation.
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 |
# File 'lib/yadriggy/ast.rb', line 476 def initialize(sexp) s = has_tag?(sexp[1], :string_content) elements = s[1..s.length] @contents = elements.map do |e| case e[0] when :string_embexpr Exprs.make(e[1]) when :@tstring_content StringLiteral.new(e) else raise "unknown string contents #{e[0]}" end end add_children(@contents) end |
Instance Attribute Details
#contents ⇒ Array<ASTnode> (readonly)
Returns the strings and the embedded expressions.
472 473 474 |
# File 'lib/yadriggy/ast.rb', line 472 def contents @contents end |
Class Method Details
.tag ⇒ Object
474 |
# File 'lib/yadriggy/ast.rb', line 474 def self.tag() :string_literal end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
495 496 497 |
# File 'lib/yadriggy/ast.rb', line 495 def accept(evaluator) evaluator.string_interpolation(self) end |