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
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(value:, location:) ⇒ EmbVar
constructor
A new instance of EmbVar.
Methods inherited from Node
#format, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ EmbVar
Returns a new instance of EmbVar.
4182 4183 4184 4185 |
# File 'lib/syntax_tree/node.rb', line 4182 def initialize(value:, location:) @value = value @location = location end |
Instance Attribute Details
#value ⇒ Object (readonly)
- String
-
the # used in the string
4180 4181 4182 |
# File 'lib/syntax_tree/node.rb', line 4180 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
4187 4188 4189 |
# File 'lib/syntax_tree/node.rb', line 4187 def accept(visitor) visitor.visit_embvar(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
4191 4192 4193 |
# File 'lib/syntax_tree/node.rb', line 4191 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
4197 4198 4199 |
# File 'lib/syntax_tree/node.rb', line 4197 def deconstruct_keys(keys) { value: value, location: location } end |