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.
11808 11809 11810 11811 11812 |
# File 'lib/syntax_tree.rb', line 11808 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
11806 11807 11808 |
# File 'lib/syntax_tree.rb', line 11806 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant being referenced
11800 11801 11802 |
# File 'lib/syntax_tree.rb', line 11800 def constant @constant end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
11803 11804 11805 |
# File 'lib/syntax_tree.rb', line 11803 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
11814 11815 11816 |
# File 'lib/syntax_tree.rb', line 11814 def child_nodes [constant] end |
#format(q) ⇒ Object
11818 11819 11820 11821 |
# File 'lib/syntax_tree.rb', line 11818 def format(q) q.text("::") q.format(constant) end |
#pretty_print(q) ⇒ Object
11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 |
# File 'lib/syntax_tree.rb', line 11823 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
11834 11835 11836 11837 11838 11839 11840 11841 |
# File 'lib/syntax_tree.rb', line 11834 def to_json(*opts) { type: :top_const_ref, constant: constant, loc: location, cmts: comments }.to_json(*opts) end |