Class: SyntaxTree::SymbolLiteral
- Inherits:
-
Object
- Object
- SyntaxTree::SymbolLiteral
- Defined in:
- lib/syntax_tree.rb
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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#value ⇒ Object
readonly
- Backtick | Const | CVar | GVar | Ident | IVar | Kw | Op
-
the value of the symbol.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ SymbolLiteral
constructor
A new instance of SymbolLiteral.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ SymbolLiteral
Returns a new instance of SymbolLiteral.
11486 11487 11488 11489 11490 |
# File 'lib/syntax_tree.rb', line 11486 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
11484 11485 11486 |
# File 'lib/syntax_tree.rb', line 11484 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
11481 11482 11483 |
# File 'lib/syntax_tree.rb', line 11481 def location @location end |
#value ⇒ Object (readonly)
- Backtick | Const | CVar | GVar | Ident | IVar | Kw | Op
-
the value of the
symbol
11478 11479 11480 |
# File 'lib/syntax_tree.rb', line 11478 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
11492 11493 11494 |
# File 'lib/syntax_tree.rb', line 11492 def child_nodes [value] end |
#format(q) ⇒ Object
11496 11497 11498 11499 |
# File 'lib/syntax_tree.rb', line 11496 def format(q) q.text(":") q.format(value) end |
#pretty_print(q) ⇒ Object
11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 |
# File 'lib/syntax_tree.rb', line 11501 def pretty_print(q) q.group(2, "(", ")") do q.text("symbol_literal") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
11512 11513 11514 11515 11516 11517 11518 11519 |
# File 'lib/syntax_tree.rb', line 11512 def to_json(*opts) { type: :symbol_literal, value: value, loc: location, cmts: comments }.to_json(*opts) end |