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.
4984 4985 4986 4987 4988 |
# File 'lib/syntax_tree/node.rb', line 4984 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
4982 4983 4984 |
# File 'lib/syntax_tree/node.rb', line 4982 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the value of the identifier
4979 4980 4981 |
# File 'lib/syntax_tree/node.rb', line 4979 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
4990 4991 4992 |
# File 'lib/syntax_tree/node.rb', line 4990 def accept(visitor) visitor.visit_ident(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
4994 4995 4996 |
# File 'lib/syntax_tree/node.rb', line 4994 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
5000 5001 5002 |
# File 'lib/syntax_tree/node.rb', line 5000 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
5004 5005 5006 |
# File 'lib/syntax_tree/node.rb', line 5004 def format(q) q.text(value) end |