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.
10435 10436 10437 10438 10439 |
# File 'lib/syntax_tree/node.rb', line 10435 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
10433 10434 10435 |
# File 'lib/syntax_tree/node.rb', line 10433 def comments @comments end |
#value ⇒ Object (readonly)
- Backtick | Const | CVar | GVar | Ident | IVar | Kw | Op
-
the value of the
symbol
10430 10431 10432 |
# File 'lib/syntax_tree/node.rb', line 10430 def value @value end |
Instance Method Details
#===(other) ⇒ Object
10471 10472 10473 |
# File 'lib/syntax_tree/node.rb', line 10471 def ===(other) other.is_a?(SymbolLiteral) && value === other.value end |
#accept(visitor) ⇒ Object
10441 10442 10443 |
# File 'lib/syntax_tree/node.rb', line 10441 def accept(visitor) visitor.visit_symbol_literal(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
10445 10446 10447 |
# File 'lib/syntax_tree/node.rb', line 10445 def child_nodes [value] end |
#copy(value: nil, location: nil) ⇒ Object
10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 |
# File 'lib/syntax_tree/node.rb', line 10449 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
10462 10463 10464 |
# File 'lib/syntax_tree/node.rb', line 10462 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
10466 10467 10468 10469 |
# File 'lib/syntax_tree/node.rb', line 10466 def format(q) q.text(":") q.format(value) end |