Class: SyntaxTree::ConstPathRef
- Inherits:
-
Object
- Object
- SyntaxTree::ConstPathRef
- Defined in:
- lib/syntax_tree.rb
Overview
ConstPathRef represents referencing a constant by a path.
object::Const
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#constant ⇒ Object
readonly
- Const
-
the constant itself.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#parent ⇒ Object
readonly
- untyped
-
the source of the constant.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(parent:, constant:, location:, comments: []) ⇒ ConstPathRef
constructor
A new instance of ConstPathRef.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(parent:, constant:, location:, comments: []) ⇒ ConstPathRef
Returns a new instance of ConstPathRef.
4126 4127 4128 4129 4130 4131 |
# File 'lib/syntax_tree.rb', line 4126 def initialize(parent:, constant:, location:, comments: []) @parent = parent @constant = constant @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
4124 4125 4126 |
# File 'lib/syntax_tree.rb', line 4124 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant itself
4118 4119 4120 |
# File 'lib/syntax_tree.rb', line 4118 def constant @constant end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
4121 4122 4123 |
# File 'lib/syntax_tree.rb', line 4121 def location @location end |
#parent ⇒ Object (readonly)
- untyped
-
the source of the constant
4115 4116 4117 |
# File 'lib/syntax_tree.rb', line 4115 def parent @parent end |
Instance Method Details
#child_nodes ⇒ Object
4133 4134 4135 |
# File 'lib/syntax_tree.rb', line 4133 def child_nodes [parent, constant] end |
#format(q) ⇒ Object
4137 4138 4139 4140 4141 |
# File 'lib/syntax_tree.rb', line 4137 def format(q) q.format(parent) q.text("::") q.format(constant) end |
#pretty_print(q) ⇒ Object
4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 |
# File 'lib/syntax_tree.rb', line 4143 def pretty_print(q) q.group(2, "(", ")") do q.text("const_path_ref") q.breakable q.pp(parent) q.breakable q.pp(constant) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
4157 4158 4159 4160 4161 4162 4163 4164 4165 |
# File 'lib/syntax_tree.rb', line 4157 def to_json(*opts) { type: :const_path_ref, parent: parent, constant: constant, loc: location, cmts: comments }.to_json(*opts) end |