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.
11888 11889 11890 11891 11892 |
# File 'lib/syntax_tree.rb', line 11888 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
11886 11887 11888 |
# File 'lib/syntax_tree.rb', line 11886 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant being referenced
11880 11881 11882 |
# File 'lib/syntax_tree.rb', line 11880 def constant @constant end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
11883 11884 11885 |
# File 'lib/syntax_tree.rb', line 11883 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
11894 11895 11896 |
# File 'lib/syntax_tree.rb', line 11894 def child_nodes [constant] end |
#format(q) ⇒ Object
11898 11899 11900 11901 |
# File 'lib/syntax_tree.rb', line 11898 def format(q) q.text("::") q.format(constant) end |
#pretty_print(q) ⇒ Object
11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 |
# File 'lib/syntax_tree.rb', line 11903 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
11914 11915 11916 11917 11918 11919 11920 11921 |
# File 'lib/syntax_tree.rb', line 11914 def to_json(*opts) { type: :top_const_ref, constant: constant, loc: location, cmts: comments }.to_json(*opts) end |