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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(constant:, location:, comments: []) ⇒ TopConstRef
Returns a new instance of TopConstRef.
8677 8678 8679 8680 8681 |
# File 'lib/syntax_tree/node.rb', line 8677 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
8675 8676 8677 |
# File 'lib/syntax_tree/node.rb', line 8675 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant being referenced
8672 8673 8674 |
# File 'lib/syntax_tree/node.rb', line 8672 def constant @constant end |
Instance Method Details
#accept(visitor) ⇒ Object
8683 8684 8685 |
# File 'lib/syntax_tree/node.rb', line 8683 def accept(visitor) visitor.visit_top_const_ref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8687 8688 8689 |
# File 'lib/syntax_tree/node.rb', line 8687 def child_nodes [constant] end |
#deconstruct_keys(_keys) ⇒ Object
8693 8694 8695 |
# File 'lib/syntax_tree/node.rb', line 8693 def deconstruct_keys(_keys) { constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
8697 8698 8699 8700 |
# File 'lib/syntax_tree/node.rb', line 8697 def format(q) q.text("::") q.format(constant) end |