Class: SyntaxTree::SymbolLiteral
Overview
SymbolLiteral represents a symbol in the system with no interpolation (as opposed to a DynaSymbol which has interpolation).
:symbol
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- Backtick | Const | CVar | GVar | Ident | IVar | Kw | Op
-
the value 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
- #format(q) ⇒ Object
-
#initialize(value:, location:) ⇒ SymbolLiteral
constructor
A new instance of SymbolLiteral.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ SymbolLiteral
Returns a new instance of SymbolLiteral.
10409 10410 10411 10412 10413 |
# File 'lib/syntax_tree/node.rb', line 10409 def initialize(value:, location:) @value = value @location = location @comments = [] end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10407 10408 10409 |
# File 'lib/syntax_tree/node.rb', line 10407 def comments @comments end |
#value ⇒ Object (readonly)
- Backtick | Const | CVar | GVar | Ident | IVar | Kw | Op
-
the value of the
symbol
10404 10405 10406 |
# File 'lib/syntax_tree/node.rb', line 10404 def value @value end |
Instance Method Details
#===(other) ⇒ Object
10445 10446 10447 |
# File 'lib/syntax_tree/node.rb', line 10445 def ===(other) other.is_a?(SymbolLiteral) && value === other.value end |
#accept(visitor) ⇒ Object
10415 10416 10417 |
# File 'lib/syntax_tree/node.rb', line 10415 def accept(visitor) visitor.visit_symbol_literal(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
10419 10420 10421 |
# File 'lib/syntax_tree/node.rb', line 10419 def child_nodes [value] end |
#copy(value: nil, location: nil) ⇒ Object
10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 |
# File 'lib/syntax_tree/node.rb', line 10423 def copy(value: nil, location: nil) node = SymbolLiteral.new( value: value || self.value, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end |
#deconstruct_keys(_keys) ⇒ Object
10436 10437 10438 |
# File 'lib/syntax_tree/node.rb', line 10436 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
10440 10441 10442 10443 |
# File 'lib/syntax_tree/node.rb', line 10440 def format(q) q.text(":") q.format(value) end |