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
Constructor Details
#initialize(constant:, location:, comments: []) ⇒ TopConstField
Returns a new instance of TopConstField.
8534 8535 8536 8537 8538 |
# File 'lib/syntax_tree/node.rb', line 8534 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
8532 8533 8534 |
# File 'lib/syntax_tree/node.rb', line 8532 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant being assigned
8529 8530 8531 |
# File 'lib/syntax_tree/node.rb', line 8529 def constant @constant end |
Instance Method Details
#accept(visitor) ⇒ Object
8540 8541 8542 |
# File 'lib/syntax_tree/node.rb', line 8540 def accept(visitor) visitor.visit_top_const_field(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8544 8545 8546 |
# File 'lib/syntax_tree/node.rb', line 8544 def child_nodes [constant] end |
#deconstruct_keys(keys) ⇒ Object
8550 8551 8552 |
# File 'lib/syntax_tree/node.rb', line 8550 def deconstruct_keys(keys) { constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
8554 8555 8556 8557 |
# File 'lib/syntax_tree/node.rb', line 8554 def format(q) q.text("::") q.format(constant) end |