Class: SyntaxTree::KwRestParam
- Inherits:
-
Object
- Object
- SyntaxTree::KwRestParam
- Defined in:
- lib/syntax_tree.rb
Overview
KwRestParam represents defining a parameter in a method definition that accepts all remaining keyword parameters.
def method(**kwargs) end
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#name ⇒ Object
readonly
- nil | Ident
-
the name of the parameter.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(name:, location:, comments: []) ⇒ KwRestParam
constructor
A new instance of KwRestParam.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(name:, location:, comments: []) ⇒ KwRestParam
Returns a new instance of KwRestParam.
7528 7529 7530 7531 7532 |
# File 'lib/syntax_tree.rb', line 7528 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
7526 7527 7528 |
# File 'lib/syntax_tree.rb', line 7526 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7523 7524 7525 |
# File 'lib/syntax_tree.rb', line 7523 def location @location end |
#name ⇒ Object (readonly)
- nil | Ident
-
the name of the parameter
7520 7521 7522 |
# File 'lib/syntax_tree.rb', line 7520 def name @name end |
Instance Method Details
#child_nodes ⇒ Object
7534 7535 7536 |
# File 'lib/syntax_tree.rb', line 7534 def child_nodes [name] end |
#format(q) ⇒ Object
7538 7539 7540 7541 |
# File 'lib/syntax_tree.rb', line 7538 def format(q) q.text("**") q.format(name) if name end |
#pretty_print(q) ⇒ Object
7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 |
# File 'lib/syntax_tree.rb', line 7543 def pretty_print(q) q.group(2, "(", ")") do q.text("kwrest_param") q.breakable q.pp(name) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
7554 7555 7556 7557 7558 7559 7560 7561 |
# File 'lib/syntax_tree.rb', line 7554 def to_json(*opts) { type: :kwrest_param, name: name, loc: location, cmts: comments }.to_json(*opts) end |