Class: SyntaxTree::ConstPathRef
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.
-
#parent ⇒ Object
readonly
- Node
-
the source of the constant.
Attributes inherited from Node
Instance Method Summary collapse
- #===(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #copy(parent: nil, constant: nil, location: nil) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(parent:, constant:, location:) ⇒ ConstPathRef
constructor
A new instance of ConstPathRef.
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(parent:, constant:, location:) ⇒ ConstPathRef
Returns a new instance of ConstPathRef.
3939 3940 3941 3942 3943 3944 |
# File 'lib/syntax_tree/node.rb', line 3939 def initialize(parent:, constant:, location:) @parent = parent @constant = constant @location = location @comments = [] end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
3937 3938 3939 |
# File 'lib/syntax_tree/node.rb', line 3937 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant itself
3934 3935 3936 |
# File 'lib/syntax_tree/node.rb', line 3934 def constant @constant end |
#parent ⇒ Object (readonly)
- Node
-
the source of the constant
3931 3932 3933 |
# File 'lib/syntax_tree/node.rb', line 3931 def parent @parent end |
Instance Method Details
#===(other) ⇒ Object
3983 3984 3985 3986 |
# File 'lib/syntax_tree/node.rb', line 3983 def ===(other) other.is_a?(ConstPathRef) && parent === other.parent && constant === other.constant end |
#accept(visitor) ⇒ Object
3946 3947 3948 |
# File 'lib/syntax_tree/node.rb', line 3946 def accept(visitor) visitor.visit_const_path_ref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
3950 3951 3952 |
# File 'lib/syntax_tree/node.rb', line 3950 def child_nodes [parent, constant] end |
#copy(parent: nil, constant: nil, location: nil) ⇒ Object
3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 |
# File 'lib/syntax_tree/node.rb', line 3954 def copy(parent: nil, constant: nil, location: nil) node = ConstPathRef.new( parent: parent || self.parent, constant: constant || self.constant, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end |
#deconstruct_keys(_keys) ⇒ Object
3968 3969 3970 3971 3972 3973 3974 3975 |
# File 'lib/syntax_tree/node.rb', line 3968 def deconstruct_keys(_keys) { parent: parent, constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
3977 3978 3979 3980 3981 |
# File 'lib/syntax_tree/node.rb', line 3977 def format(q) q.format(parent) q.text("::") q.format(constant) end |