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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(parent:, constant:, location:, comments: []) ⇒ ConstPathRef
Returns a new instance of ConstPathRef.
3281 3282 3283 3284 3285 3286 |
# File 'lib/syntax_tree/node.rb', line 3281 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
3279 3280 3281 |
# File 'lib/syntax_tree/node.rb', line 3279 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant itself
3276 3277 3278 |
# File 'lib/syntax_tree/node.rb', line 3276 def constant @constant end |
#parent ⇒ Object (readonly)
- untyped
-
the source of the constant
3273 3274 3275 |
# File 'lib/syntax_tree/node.rb', line 3273 def parent @parent end |
Instance Method Details
#accept(visitor) ⇒ Object
3288 3289 3290 |
# File 'lib/syntax_tree/node.rb', line 3288 def accept(visitor) visitor.visit_const_path_ref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
3292 3293 3294 |
# File 'lib/syntax_tree/node.rb', line 3292 def child_nodes [parent, constant] end |
#deconstruct_keys(_keys) ⇒ Object
3298 3299 3300 3301 3302 3303 3304 3305 |
# File 'lib/syntax_tree/node.rb', line 3298 def deconstruct_keys(_keys) { parent: parent, constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
3307 3308 3309 3310 3311 |
# File 'lib/syntax_tree/node.rb', line 3307 def format(q) q.format(parent) q.text("::") q.format(constant) end |