Class: SyntaxTree::ConstPathRef
- Inherits:
-
Object
- Object
- SyntaxTree::ConstPathRef
- Defined in:
- lib/syntax_tree.rb
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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#parent ⇒ Object
readonly
- untyped
-
the source of the constant.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(parent:, constant:, location:, comments: []) ⇒ ConstPathRef
constructor
A new instance of ConstPathRef.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(parent:, constant:, location:, comments: []) ⇒ ConstPathRef
Returns a new instance of ConstPathRef.
4163 4164 4165 4166 4167 4168 |
# File 'lib/syntax_tree.rb', line 4163 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
4161 4162 4163 |
# File 'lib/syntax_tree.rb', line 4161 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant itself
4155 4156 4157 |
# File 'lib/syntax_tree.rb', line 4155 def constant @constant end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
4158 4159 4160 |
# File 'lib/syntax_tree.rb', line 4158 def location @location end |
#parent ⇒ Object (readonly)
- untyped
-
the source of the constant
4152 4153 4154 |
# File 'lib/syntax_tree.rb', line 4152 def parent @parent end |
Instance Method Details
#child_nodes ⇒ Object
4170 4171 4172 |
# File 'lib/syntax_tree.rb', line 4170 def child_nodes [parent, constant] end |
#format(q) ⇒ Object
4174 4175 4176 4177 4178 |
# File 'lib/syntax_tree.rb', line 4174 def format(q) q.format(parent) q.text("::") q.format(constant) end |
#pretty_print(q) ⇒ Object
4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 |
# File 'lib/syntax_tree.rb', line 4180 def pretty_print(q) q.group(2, "(", ")") do q.text("const_path_ref") q.breakable q.pp(parent) q.breakable q.pp(constant) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
4194 4195 4196 4197 4198 4199 4200 4201 4202 |
# File 'lib/syntax_tree.rb', line 4194 def to_json(*opts) { type: :const_path_ref, parent: parent, constant: constant, loc: location, cmts: comments }.to_json(*opts) end |