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.
7046 7047 7048 7049 7050 |
# File 'lib/syntax_tree/node.rb', line 7046 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
7044 7045 7046 |
# File 'lib/syntax_tree/node.rb', line 7044 def comments @comments end |
#name ⇒ Object (readonly)
- nil | Ident
-
the name of the parameter
7041 7042 7043 |
# File 'lib/syntax_tree/node.rb', line 7041 def name @name end |
Instance Method Details
#accept(visitor) ⇒ Object
7052 7053 7054 |
# File 'lib/syntax_tree/node.rb', line 7052 def accept(visitor) visitor.visit_rest_param(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7056 7057 7058 |
# File 'lib/syntax_tree/node.rb', line 7056 def child_nodes [name] end |
#deconstruct_keys(keys) ⇒ Object
7062 7063 7064 |
# File 'lib/syntax_tree/node.rb', line 7062 def deconstruct_keys(keys) { name: name, location: location, comments: comments } end |
#format(q) ⇒ Object
7066 7067 7068 7069 |
# File 'lib/syntax_tree/node.rb', line 7066 def format(q) q.text("*") q.format(name) if name end |