Class: SyntaxTree::SymBeg
Overview
SymBeg represents the beginning of a symbol literal.
:symbol
SymBeg is also used for dynamic symbols, as in:
:"symbol"
Finally, SymBeg is also used for symbols using the %s syntax, as in:
s[symbol]
The value of this node is a string. In most cases (as in the first example above) it will contain just “:”. In the case of dynamic symbols it will contain “:‘” or “:"”. In the case of %s symbols, it will contain the start of the symbol including the %s and the delimiter.
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
- String
-
the beginning of the symbol.
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:) ⇒ SymBeg
constructor
A new instance of SymBeg.
Methods inherited from Node
#construct_keys, #end_char, #format, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ SymBeg
Returns a new instance of SymBeg.
10442 10443 10444 10445 |
# File 'lib/syntax_tree/node.rb', line 10442 def initialize(value:, location:) @value = value @location = location end |
Instance Attribute Details
#value ⇒ Object (readonly)
- String
-
the beginning of the symbol
10440 10441 10442 |
# File 'lib/syntax_tree/node.rb', line 10440 def value @value end |
Instance Method Details
#===(other) ⇒ Object
10468 10469 10470 |
# File 'lib/syntax_tree/node.rb', line 10468 def ===(other) other.is_a?(SymBeg) && value === other.value end |
#accept(visitor) ⇒ Object
10447 10448 10449 |
# File 'lib/syntax_tree/node.rb', line 10447 def accept(visitor) visitor.visit_symbeg(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
10451 10452 10453 |
# File 'lib/syntax_tree/node.rb', line 10451 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
10455 10456 10457 10458 10459 10460 |
# File 'lib/syntax_tree/node.rb', line 10455 def copy(value: nil, location: nil) SymBeg.new( value: value || self.value, location: location || self.location ) end |
#deconstruct_keys(_keys) ⇒ Object
10464 10465 10466 |
# File 'lib/syntax_tree/node.rb', line 10464 def deconstruct_keys(_keys) { value: value, location: location } end |