Class: SyntaxTree::RestParam
Overview
RestParam represents defining a parameter in a method definition that accepts all remaining positional parameters.
def method(*rest) end
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#name ⇒ Object
readonly
- nil | Ident
-
the name of the parameter.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(name:, location:, comments: []) ⇒ RestParam
constructor
A new instance of RestParam.
Methods inherited from Node
Constructor Details
#initialize(name:, location:, comments: []) ⇒ RestParam
Returns a new instance of RestParam.
7589 7590 7591 7592 7593 |
# File 'lib/syntax_tree/node.rb', line 7589 def initialize(name:, location:, comments: []) @name = name @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7587 7588 7589 |
# File 'lib/syntax_tree/node.rb', line 7587 def comments @comments end |
#name ⇒ Object (readonly)
- nil | Ident
-
the name of the parameter
7584 7585 7586 |
# File 'lib/syntax_tree/node.rb', line 7584 def name @name end |
Instance Method Details
#accept(visitor) ⇒ Object
7595 7596 7597 |
# File 'lib/syntax_tree/node.rb', line 7595 def accept(visitor) visitor.visit_rest_param(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7599 7600 7601 |
# File 'lib/syntax_tree/node.rb', line 7599 def child_nodes [name] end |
#deconstruct_keys(keys) ⇒ Object
7605 7606 7607 |
# File 'lib/syntax_tree/node.rb', line 7605 def deconstruct_keys(keys) { name: name, location: location, comments: comments } end |
#format(q) ⇒ Object
7609 7610 7611 7612 |
# File 'lib/syntax_tree/node.rb', line 7609 def format(q) q.text("*") q.format(name) if name end |