Class: SyntaxTree::ConstPathField
Overview
ConstPathField represents the child node of some kind of assignment. It represents when you’re assigning to a constant that is being referenced as a child of another variable.
object::Const = value
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#constant ⇒ Object
readonly
- Const
-
the constant itself.
-
#parent ⇒ Object
readonly
- untyped
-
the source of the constant.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(parent:, constant:, location:, comments: []) ⇒ ConstPathField
constructor
A new instance of ConstPathField.
Methods inherited from Node
Constructor Details
#initialize(parent:, constant:, location:, comments: []) ⇒ ConstPathField
Returns a new instance of ConstPathField.
3170 3171 3172 3173 3174 3175 |
# File 'lib/syntax_tree/node.rb', line 3170 def initialize(parent:, constant:, location:, comments: []) @parent = parent @constant = constant @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
3168 3169 3170 |
# File 'lib/syntax_tree/node.rb', line 3168 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant itself
3165 3166 3167 |
# File 'lib/syntax_tree/node.rb', line 3165 def constant @constant end |
#parent ⇒ Object (readonly)
- untyped
-
the source of the constant
3162 3163 3164 |
# File 'lib/syntax_tree/node.rb', line 3162 def parent @parent end |
Instance Method Details
#accept(visitor) ⇒ Object
3177 3178 3179 |
# File 'lib/syntax_tree/node.rb', line 3177 def accept(visitor) visitor.visit_const_path_field(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
3181 3182 3183 |
# File 'lib/syntax_tree/node.rb', line 3181 def child_nodes [parent, constant] end |
#deconstruct_keys(keys) ⇒ Object
3187 3188 3189 3190 3191 3192 3193 3194 |
# File 'lib/syntax_tree/node.rb', line 3187 def deconstruct_keys(keys) { parent: parent, constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
3196 3197 3198 3199 3200 |
# File 'lib/syntax_tree/node.rb', line 3196 def format(q) q.format(parent) q.text("::") q.format(constant) end |