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.
10400 10401 10402 10403 10404 |
# File 'lib/syntax_tree/node.rb', line 10400 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
10398 10399 10400 |
# File 'lib/syntax_tree/node.rb', line 10398 def comments @comments end |
#value ⇒ Object (readonly)
- Backtick | Const | CVar | GVar | Ident | IVar | Kw | Op
-
the value of the
symbol
10395 10396 10397 |
# File 'lib/syntax_tree/node.rb', line 10395 def value @value end |
Instance Method Details
#===(other) ⇒ Object
10436 10437 10438 |
# File 'lib/syntax_tree/node.rb', line 10436 def ===(other) other.is_a?(SymbolLiteral) && value === other.value end |
#accept(visitor) ⇒ Object
10406 10407 10408 |
# File 'lib/syntax_tree/node.rb', line 10406 def accept(visitor) visitor.visit_symbol_literal(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
10410 10411 10412 |
# File 'lib/syntax_tree/node.rb', line 10410 def child_nodes [value] end |
#copy(value: nil, location: nil) ⇒ Object
10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 |
# File 'lib/syntax_tree/node.rb', line 10414 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
10427 10428 10429 |
# File 'lib/syntax_tree/node.rb', line 10427 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
10431 10432 10433 10434 |
# File 'lib/syntax_tree/node.rb', line 10431 def format(q) q.text(":") q.format(value) end |