Class: SyntaxTree::TopConstField
Overview
TopConstField is always the child node of some kind of assignment. It represents when you’re assigning to a constant that is being referenced at the top level.
::Constant = value
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#constant ⇒ Object
readonly
- Const
-
the constant being assigned.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(constant:, location:, comments: []) ⇒ TopConstField
constructor
A new instance of TopConstField.
Methods inherited from Node
Constructor Details
#initialize(constant:, location:, comments: []) ⇒ TopConstField
Returns a new instance of TopConstField.
7990 7991 7992 7993 7994 |
# File 'lib/syntax_tree/node.rb', line 7990 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
7988 7989 7990 |
# File 'lib/syntax_tree/node.rb', line 7988 def comments @comments end |
#constant ⇒ Object (readonly)
- Const
-
the constant being assigned
7985 7986 7987 |
# File 'lib/syntax_tree/node.rb', line 7985 def constant @constant end |
Instance Method Details
#accept(visitor) ⇒ Object
7996 7997 7998 |
# File 'lib/syntax_tree/node.rb', line 7996 def accept(visitor) visitor.visit_top_const_field(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8000 8001 8002 |
# File 'lib/syntax_tree/node.rb', line 8000 def child_nodes [constant] end |
#deconstruct_keys(keys) ⇒ Object
8006 8007 8008 |
# File 'lib/syntax_tree/node.rb', line 8006 def deconstruct_keys(keys) { constant: constant, location: location, comments: comments } end |
#format(q) ⇒ Object
8010 8011 8012 8013 |
# File 'lib/syntax_tree/node.rb', line 8010 def format(q) q.text("::") q.format(constant) end |