Class: SyntaxTree::TopConstField
Overview
TopConstField is always the child node of some kind of assignment. It represents when you’re assigning to a constant that is being referenced at the top level.
::Constant = value
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#constant ⇒ Object
readonly
- Const
-
the constant being assigned.
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: []) ⇒ TopConstField
constructor
A new instance of TopConstField.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(constant:, location:, comments: []) ⇒ TopConstField
Returns a new instance of TopConstField.
8803 8804 8805 8806 8807 |
# File 'lib/syntax_tree/node.rb', line 8803 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
8801 8802 8803 |
# File 'lib/syntax_tree/node.rb', line 8801 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant being assigned
8798 8799 8800 |
# File 'lib/syntax_tree/node.rb', line 8798 def constant @constant end |
Instance Method Details
#accept(visitor) ⇒ Object
8809 8810 8811 |
# File 'lib/syntax_tree/node.rb', line 8809 def accept(visitor) visitor.visit_top_const_field(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8813 8814 8815 |
# File 'lib/syntax_tree/node.rb', line 8813 def child_nodes [constant] end |
#deconstruct_keys(_keys) ⇒ Object
8819 8820 8821 |
# File 'lib/syntax_tree/node.rb', line 8819 def deconstruct_keys(_keys) { constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
8823 8824 8825 8826 |
# File 'lib/syntax_tree/node.rb', line 8823 def format(q) q.text("::") q.format(constant) end |