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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(name:, location:, comments: []) ⇒ RestParam
Returns a new instance of RestParam.
7767 7768 7769 7770 7771 |
# File 'lib/syntax_tree/node.rb', line 7767 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
7765 7766 7767 |
# File 'lib/syntax_tree/node.rb', line 7765 def comments @comments end |
#name ⇒ Object (readonly)
- nil | Ident
-
the name of the parameter
7762 7763 7764 |
# File 'lib/syntax_tree/node.rb', line 7762 def name @name end |
Instance Method Details
#accept(visitor) ⇒ Object
7773 7774 7775 |
# File 'lib/syntax_tree/node.rb', line 7773 def accept(visitor) visitor.visit_rest_param(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7777 7778 7779 |
# File 'lib/syntax_tree/node.rb', line 7777 def child_nodes [name] end |
#deconstruct_keys(_keys) ⇒ Object
7783 7784 7785 |
# File 'lib/syntax_tree/node.rb', line 7783 def deconstruct_keys(_keys) { name: name, location: location, comments: comments } end |
#format(q) ⇒ Object
7787 7788 7789 7790 |
# File 'lib/syntax_tree/node.rb', line 7787 def format(q) q.text("*") q.format(name) if name end |