Class: SyntaxTree::TopConstRef
Overview
TopConstRef is very similar to TopConstField except that it is not involved in an assignment.
::Constant
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#constant ⇒ Object
readonly
- Const
-
the constant being referenced.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(constant:, location:, comments: []) ⇒ TopConstRef
constructor
A new instance of TopConstRef.
Methods inherited from Node
Constructor Details
#initialize(constant:, location:, comments: []) ⇒ TopConstRef
Returns a new instance of TopConstRef.
8572 8573 8574 8575 8576 |
# File 'lib/syntax_tree/node.rb', line 8572 def initialize(constant:, location:, comments: []) @constant = constant @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8570 8571 8572 |
# File 'lib/syntax_tree/node.rb', line 8570 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant being referenced
8567 8568 8569 |
# File 'lib/syntax_tree/node.rb', line 8567 def constant @constant end |
Instance Method Details
#accept(visitor) ⇒ Object
8578 8579 8580 |
# File 'lib/syntax_tree/node.rb', line 8578 def accept(visitor) visitor.visit_top_const_ref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8582 8583 8584 |
# File 'lib/syntax_tree/node.rb', line 8582 def child_nodes [constant] end |
#deconstruct_keys(keys) ⇒ Object
8588 8589 8590 |
# File 'lib/syntax_tree/node.rb', line 8588 def deconstruct_keys(keys) { constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
8592 8593 8594 8595 |
# File 'lib/syntax_tree/node.rb', line 8592 def format(q) q.text("::") q.format(constant) end |