Class: SyntaxTree::TopConstRef
- Inherits:
-
Object
- Object
- SyntaxTree::TopConstRef
- Defined in:
- lib/syntax_tree.rb
Overview
TopConstRef is very similar to TopConstField except that it is not involved in an assignment.
::Constant
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#constant ⇒ Object
readonly
- Const
-
the constant being referenced.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(constant:, location:, comments: []) ⇒ TopConstRef
constructor
A new instance of TopConstRef.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(constant:, location:, comments: []) ⇒ TopConstRef
Returns a new instance of TopConstRef.
11308 11309 11310 11311 11312 |
# File 'lib/syntax_tree.rb', line 11308 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
11306 11307 11308 |
# File 'lib/syntax_tree.rb', line 11306 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant being referenced
11300 11301 11302 |
# File 'lib/syntax_tree.rb', line 11300 def constant @constant end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
11303 11304 11305 |
# File 'lib/syntax_tree.rb', line 11303 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
11314 11315 11316 |
# File 'lib/syntax_tree.rb', line 11314 def child_nodes [constant] end |
#format(q) ⇒ Object
11318 11319 11320 11321 |
# File 'lib/syntax_tree.rb', line 11318 def format(q) q.text("::") q.format(constant) end |
#pretty_print(q) ⇒ Object
11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 |
# File 'lib/syntax_tree.rb', line 11323 def pretty_print(q) q.group(2, "(", ")") do q.text("top_const_ref") q.breakable q.pp(constant) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
11334 11335 11336 11337 11338 11339 11340 11341 |
# File 'lib/syntax_tree.rb', line 11334 def to_json(*opts) { type: :top_const_ref, constant: constant, loc: location, cmts: comments }.to_json(*opts) end |