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.
12020 12021 12022 12023 12024 |
# File 'lib/syntax_tree.rb', line 12020 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
12018 12019 12020 |
# File 'lib/syntax_tree.rb', line 12018 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant being referenced
12012 12013 12014 |
# File 'lib/syntax_tree.rb', line 12012 def constant @constant end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
12015 12016 12017 |
# File 'lib/syntax_tree.rb', line 12015 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
12026 12027 12028 |
# File 'lib/syntax_tree.rb', line 12026 def child_nodes [constant] end |
#format(q) ⇒ Object
12030 12031 12032 12033 |
# File 'lib/syntax_tree.rb', line 12030 def format(q) q.text("::") q.format(constant) end |
#pretty_print(q) ⇒ Object
12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 |
# File 'lib/syntax_tree.rb', line 12035 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
12046 12047 12048 12049 12050 12051 12052 12053 |
# File 'lib/syntax_tree.rb', line 12046 def to_json(*opts) { type: :top_const_ref, constant: constant, loc: location, cmts: comments }.to_json(*opts) end |