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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Ident
Returns a new instance of Ident.
5157 5158 5159 5160 5161 |
# File 'lib/syntax_tree/node.rb', line 5157 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
5155 5156 5157 |
# File 'lib/syntax_tree/node.rb', line 5155 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the value of the identifier
5152 5153 5154 |
# File 'lib/syntax_tree/node.rb', line 5152 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
5163 5164 5165 |
# File 'lib/syntax_tree/node.rb', line 5163 def accept(visitor) visitor.visit_ident(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5167 5168 5169 |
# File 'lib/syntax_tree/node.rb', line 5167 def child_nodes [] end |
#deconstruct_keys(_keys) ⇒ Object
5173 5174 5175 |
# File 'lib/syntax_tree/node.rb', line 5173 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
5177 5178 5179 |
# File 'lib/syntax_tree/node.rb', line 5177 def format(q) q.text(value) end |