Class: SyntaxTree::ConstPathRef
Overview
ConstPathRef represents referencing a constant by a path.
object::Const
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: []) ⇒ ConstPathRef
constructor
A new instance of ConstPathRef.
Methods inherited from Node
Constructor Details
#initialize(parent:, constant:, location:, comments: []) ⇒ ConstPathRef
Returns a new instance of ConstPathRef.
3216 3217 3218 3219 3220 3221 |
# File 'lib/syntax_tree/node.rb', line 3216 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
3214 3215 3216 |
# File 'lib/syntax_tree/node.rb', line 3214 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant itself
3211 3212 3213 |
# File 'lib/syntax_tree/node.rb', line 3211 def constant @constant end |
#parent ⇒ Object (readonly)
- untyped
-
the source of the constant
3208 3209 3210 |
# File 'lib/syntax_tree/node.rb', line 3208 def parent @parent end |
Instance Method Details
#accept(visitor) ⇒ Object
3223 3224 3225 |
# File 'lib/syntax_tree/node.rb', line 3223 def accept(visitor) visitor.visit_const_path_ref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
3227 3228 3229 |
# File 'lib/syntax_tree/node.rb', line 3227 def child_nodes [parent, constant] end |
#deconstruct_keys(keys) ⇒ Object
3233 3234 3235 3236 3237 3238 3239 3240 |
# File 'lib/syntax_tree/node.rb', line 3233 def deconstruct_keys(keys) { parent: parent, constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
3242 3243 3244 3245 3246 |
# File 'lib/syntax_tree/node.rb', line 3242 def format(q) q.format(parent) q.text("::") q.format(constant) end |