Class: SyntaxTree::ConstRef
- Inherits:
-
Object
- Object
- SyntaxTree::ConstRef
- Defined in:
- lib/syntax_tree.rb
Overview
ConstRef represents the name of the constant being used in a class or module declaration.
class Container
end
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.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(constant:, location:, comments: []) ⇒ ConstRef
constructor
A new instance of ConstRef.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(constant:, location:, comments: []) ⇒ ConstRef
Returns a new instance of ConstRef.
4194 4195 4196 4197 4198 |
# File 'lib/syntax_tree.rb', line 4194 def initialize(constant:, location:, comments: []) @constant = constant @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
4192 4193 4194 |
# File 'lib/syntax_tree.rb', line 4192 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant itself
4186 4187 4188 |
# File 'lib/syntax_tree.rb', line 4186 def constant @constant end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
4189 4190 4191 |
# File 'lib/syntax_tree.rb', line 4189 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
4200 4201 4202 |
# File 'lib/syntax_tree.rb', line 4200 def child_nodes [constant] end |
#format(q) ⇒ Object
4204 4205 4206 |
# File 'lib/syntax_tree.rb', line 4204 def format(q) q.format(constant) end |
#pretty_print(q) ⇒ Object
4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 |
# File 'lib/syntax_tree.rb', line 4208 def pretty_print(q) q.group(2, "(", ")") do q.text("const_ref") q.breakable q.pp(constant) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
4219 4220 4221 4222 4223 4224 4225 4226 |
# File 'lib/syntax_tree.rb', line 4219 def to_json(*opts) { type: :const_ref, constant: constant, loc: location, cmts: comments }.to_json(*opts) end |