Class: SyntaxTree::TopConstRef
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.
Attributes inherited from Node
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ 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.
9816 9817 9818 9819 9820 |
# File 'lib/syntax_tree/node.rb', line 9816 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
9814 9815 9816 |
# File 'lib/syntax_tree/node.rb', line 9814 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant being referenced
9811 9812 9813 |
# File 'lib/syntax_tree/node.rb', line 9811 def constant @constant end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
9822 9823 9824 |
# File 'lib/syntax_tree/node.rb', line 9822 def child_nodes [constant] end |
#deconstruct_keys(keys) ⇒ Object
9828 9829 9830 |
# File 'lib/syntax_tree/node.rb', line 9828 def deconstruct_keys(keys) { constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
9832 9833 9834 9835 |
# File 'lib/syntax_tree/node.rb', line 9832 def format(q) q.text("::") q.format(constant) end |
#pretty_print(q) ⇒ Object
9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 |
# File 'lib/syntax_tree/node.rb', line 9837 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
9848 9849 9850 9851 9852 9853 9854 9855 |
# File 'lib/syntax_tree/node.rb', line 9848 def to_json(*opts) { type: :top_const_ref, constant: constant, loc: location, cmts: comments }.to_json(*opts) end |