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
- untyped
-
the source of the constant.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(parent:, constant:, location:, comments: []) ⇒ ConstPathRef
constructor
A new instance of ConstPathRef.
Methods inherited from Node
Constructor Details
#initialize(parent:, constant:, location:, comments: []) ⇒ ConstPathRef
Returns a new instance of ConstPathRef.
2868 2869 2870 2871 2872 2873 |
# File 'lib/syntax_tree/node.rb', line 2868 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
2866 2867 2868 |
# File 'lib/syntax_tree/node.rb', line 2866 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant itself
2863 2864 2865 |
# File 'lib/syntax_tree/node.rb', line 2863 def constant @constant end |
#parent ⇒ Object (readonly)
- untyped
-
the source of the constant
2860 2861 2862 |
# File 'lib/syntax_tree/node.rb', line 2860 def parent @parent end |
Instance Method Details
#accept(visitor) ⇒ Object
2875 2876 2877 |
# File 'lib/syntax_tree/node.rb', line 2875 def accept(visitor) visitor.visit_const_path_ref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2879 2880 2881 |
# File 'lib/syntax_tree/node.rb', line 2879 def child_nodes [parent, constant] end |
#deconstruct_keys(keys) ⇒ Object
2885 2886 2887 2888 2889 2890 2891 2892 |
# File 'lib/syntax_tree/node.rb', line 2885 def deconstruct_keys(keys) { parent: parent, constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
2894 2895 2896 2897 2898 |
# File 'lib/syntax_tree/node.rb', line 2894 def format(q) q.format(parent) q.text("::") q.format(constant) end |