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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(parent:, constant:, location:, comments: []) ⇒ ConstPathField
Returns a new instance of ConstPathField.
3202 3203 3204 3205 3206 3207 |
# File 'lib/syntax_tree/node.rb', line 3202 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
3200 3201 3202 |
# File 'lib/syntax_tree/node.rb', line 3200 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant itself
3197 3198 3199 |
# File 'lib/syntax_tree/node.rb', line 3197 def constant @constant end |
#parent ⇒ Object (readonly)
- untyped
-
the source of the constant
3194 3195 3196 |
# File 'lib/syntax_tree/node.rb', line 3194 def parent @parent end |
Instance Method Details
#accept(visitor) ⇒ Object
3209 3210 3211 |
# File 'lib/syntax_tree/node.rb', line 3209 def accept(visitor) visitor.visit_const_path_field(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
3213 3214 3215 |
# File 'lib/syntax_tree/node.rb', line 3213 def child_nodes [parent, constant] end |
#deconstruct_keys(_keys) ⇒ Object
3219 3220 3221 3222 3223 3224 3225 3226 |
# File 'lib/syntax_tree/node.rb', line 3219 def deconstruct_keys(_keys) { parent: parent, constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
3228 3229 3230 3231 3232 |
# File 'lib/syntax_tree/node.rb', line 3228 def format(q) q.format(parent) q.text("::") q.format(constant) end |