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, #format, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ EmbVar
Returns a new instance of EmbVar.
5028 5029 5030 5031 |
# File 'lib/syntax_tree/node.rb', line 5028 def initialize(value:, location:) @value = value @location = location end |
Instance Attribute Details
#value ⇒ Object (readonly)
- String
-
the # used in the string
5026 5027 5028 |
# File 'lib/syntax_tree/node.rb', line 5026 def value @value end |
Instance Method Details
#===(other) ⇒ Object
5054 5055 5056 |
# File 'lib/syntax_tree/node.rb', line 5054 def ===(other) other.is_a?(EmbVar) && value === other.value end |
#accept(visitor) ⇒ Object
5033 5034 5035 |
# File 'lib/syntax_tree/node.rb', line 5033 def accept(visitor) visitor.visit_embvar(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5037 5038 5039 |
# File 'lib/syntax_tree/node.rb', line 5037 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
5041 5042 5043 5044 5045 5046 |
# File 'lib/syntax_tree/node.rb', line 5041 def copy(value: nil, location: nil) EmbVar.new( value: value || self.value, location: location || self.location ) end |
#deconstruct_keys(_keys) ⇒ Object
5050 5051 5052 |
# File 'lib/syntax_tree/node.rb', line 5050 def deconstruct_keys(_keys) { value: value, location: location } end |