Class: SyntaxTree::EmbVar
Overview
EmbVar represents the use of shorthand interpolation for an instance, class, or global variable into a parent node that accepts string content (like a string or regular expression).
"#@variable"
In the example above, an EmbVar node represents the # because it forces
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
- String
-
the # used in the string.
Attributes inherited from Node
Instance Method Summary collapse
- #===(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #copy(value: nil, location: nil) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
-
#initialize(value:, location:) ⇒ EmbVar
constructor
A new instance of EmbVar.
Methods inherited from Node
#construct_keys, #end_char, #format, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ EmbVar
Returns a new instance of EmbVar.
5123 5124 5125 5126 |
# File 'lib/syntax_tree/node.rb', line 5123 def initialize(value:, location:) @value = value @location = location end |
Instance Attribute Details
#value ⇒ Object (readonly)
- String
-
the # used in the string
5121 5122 5123 |
# File 'lib/syntax_tree/node.rb', line 5121 def value @value end |
Instance Method Details
#===(other) ⇒ Object
5149 5150 5151 |
# File 'lib/syntax_tree/node.rb', line 5149 def ===(other) other.is_a?(EmbVar) && value === other.value end |
#accept(visitor) ⇒ Object
5128 5129 5130 |
# File 'lib/syntax_tree/node.rb', line 5128 def accept(visitor) visitor.visit_embvar(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5132 5133 5134 |
# File 'lib/syntax_tree/node.rb', line 5132 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
5136 5137 5138 5139 5140 5141 |
# File 'lib/syntax_tree/node.rb', line 5136 def copy(value: nil, location: nil) EmbVar.new( value: value || self.value, location: location || self.location ) end |
#deconstruct_keys(_keys) ⇒ Object
5145 5146 5147 |
# File 'lib/syntax_tree/node.rb', line 5145 def deconstruct_keys(_keys) { value: value, location: location } end |