Class: SyntaxTree::Const
Overview
Const represents a literal value that looks like a constant. This could actually be a reference to a constant:
Constant
It could also be something that looks like a constant in another context, as in a method call to a capitalized method:
object.Constant
or a symbol that starts with a capital letter:
:Constant
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- String
-
the name 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(value:, location:, comments: []) ⇒ Const
constructor
A new instance of Const.
Methods inherited from Node
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Const
Returns a new instance of Const.
2780 2781 2782 2783 2784 |
# File 'lib/syntax_tree/node.rb', line 2780 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2778 2779 2780 |
# File 'lib/syntax_tree/node.rb', line 2778 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the name of the constant
2775 2776 2777 |
# File 'lib/syntax_tree/node.rb', line 2775 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
2786 2787 2788 |
# File 'lib/syntax_tree/node.rb', line 2786 def accept(visitor) visitor.visit_const(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2790 2791 2792 |
# File 'lib/syntax_tree/node.rb', line 2790 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
2796 2797 2798 |
# File 'lib/syntax_tree/node.rb', line 2796 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
2800 2801 2802 |
# File 'lib/syntax_tree/node.rb', line 2800 def format(q) q.text(value) end |