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.
5014 5015 5016 5017 |
# File 'lib/syntax_tree/node.rb', line 5014 def initialize(value:, location:) @value = value @location = location end |
Instance Attribute Details
#value ⇒ Object (readonly)
- String
-
the # used in the string
5012 5013 5014 |
# File 'lib/syntax_tree/node.rb', line 5012 def value @value end |
Instance Method Details
#===(other) ⇒ Object
5040 5041 5042 |
# File 'lib/syntax_tree/node.rb', line 5040 def ===(other) other.is_a?(EmbVar) && value === other.value end |
#accept(visitor) ⇒ Object
5019 5020 5021 |
# File 'lib/syntax_tree/node.rb', line 5019 def accept(visitor) visitor.visit_embvar(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5023 5024 5025 |
# File 'lib/syntax_tree/node.rb', line 5023 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
5027 5028 5029 5030 5031 5032 |
# File 'lib/syntax_tree/node.rb', line 5027 def copy(value: nil, location: nil) EmbVar.new( value: value || self.value, location: location || self.location ) end |
#deconstruct_keys(_keys) ⇒ Object
5036 5037 5038 |
# File 'lib/syntax_tree/node.rb', line 5036 def deconstruct_keys(_keys) { value: value, location: location } end |