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.
5105 5106 5107 5108 |
# File 'lib/syntax_tree/node.rb', line 5105 def initialize(value:, location:) @value = value @location = location end |
Instance Attribute Details
#value ⇒ Object (readonly)
- String
-
the # used in the string
5103 5104 5105 |
# File 'lib/syntax_tree/node.rb', line 5103 def value @value end |
Instance Method Details
#===(other) ⇒ Object
5131 5132 5133 |
# File 'lib/syntax_tree/node.rb', line 5131 def ===(other) other.is_a?(EmbVar) && value === other.value end |
#accept(visitor) ⇒ Object
5110 5111 5112 |
# File 'lib/syntax_tree/node.rb', line 5110 def accept(visitor) visitor.visit_embvar(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5114 5115 5116 |
# File 'lib/syntax_tree/node.rb', line 5114 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
5118 5119 5120 5121 5122 5123 |
# File 'lib/syntax_tree/node.rb', line 5118 def copy(value: nil, location: nil) EmbVar.new( value: value || self.value, location: location || self.location ) end |
#deconstruct_keys(_keys) ⇒ Object
5127 5128 5129 |
# File 'lib/syntax_tree/node.rb', line 5127 def deconstruct_keys(_keys) { value: value, location: location } end |