Class: SyntaxTree::Ident
Overview
Ident represents an identifier anywhere in code. It can represent a very large number of things, depending on where it is in the syntax tree.
value
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- String
-
the value of the identifier.
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: []) ⇒ Ident
constructor
A new instance of Ident.
Methods inherited from Node
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Ident
Returns a new instance of Ident.
4576 4577 4578 4579 4580 |
# File 'lib/syntax_tree/node.rb', line 4576 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
4574 4575 4576 |
# File 'lib/syntax_tree/node.rb', line 4574 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the value of the identifier
4571 4572 4573 |
# File 'lib/syntax_tree/node.rb', line 4571 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
4582 4583 4584 |
# File 'lib/syntax_tree/node.rb', line 4582 def accept(visitor) visitor.visit_ident(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
4586 4587 4588 |
# File 'lib/syntax_tree/node.rb', line 4586 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
4592 4593 4594 |
# File 'lib/syntax_tree/node.rb', line 4592 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
4596 4597 4598 |
# File 'lib/syntax_tree/node.rb', line 4596 def format(q) q.text(value) end |