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
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ SymbolLiteral
constructor
A new instance of SymbolLiteral.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:, comments: []) ⇒ SymbolLiteral
Returns a new instance of SymbolLiteral.
8627 8628 8629 8630 8631 |
# File 'lib/syntax_tree/node.rb', line 8627 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8625 8626 8627 |
# File 'lib/syntax_tree/node.rb', line 8625 def comments @comments end |
#value ⇒ Object (readonly)
- Backtick | Const | CVar | GVar | Ident | IVar | Kw | Op
-
the value of the
symbol
8622 8623 8624 |
# File 'lib/syntax_tree/node.rb', line 8622 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
8633 8634 8635 |
# File 'lib/syntax_tree/node.rb', line 8633 def accept(visitor) visitor.visit_symbol_literal(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8637 8638 8639 |
# File 'lib/syntax_tree/node.rb', line 8637 def child_nodes [value] end |
#deconstruct_keys(_keys) ⇒ Object
8643 8644 8645 |
# File 'lib/syntax_tree/node.rb', line 8643 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
8647 8648 8649 8650 |
# File 'lib/syntax_tree/node.rb', line 8647 def format(q) q.text(":") q.format(value) end |