Class: SyntaxTree::KwRestParam
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 (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ 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.
6707 6708 6709 6710 6711 |
# File 'lib/syntax_tree/node.rb', line 6707 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
6705 6706 6707 |
# File 'lib/syntax_tree/node.rb', line 6705 def comments @comments end |
#location ⇒ Object (readonly)
[Location] the location of this node
6702 6703 6704 |
# File 'lib/syntax_tree/node.rb', line 6702 def location @location end |
#name ⇒ Object (readonly)
[nil | Ident] the name of the parameter
6699 6700 6701 |
# File 'lib/syntax_tree/node.rb', line 6699 def name @name end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
6713 6714 6715 |
# File 'lib/syntax_tree/node.rb', line 6713 def child_nodes [name] end |
#deconstruct_keys(keys) ⇒ Object
6719 6720 6721 |
# File 'lib/syntax_tree/node.rb', line 6719 def deconstruct_keys(keys) { name: name, location: location, comments: comments } end |
#format(q) ⇒ Object
6723 6724 6725 6726 |
# File 'lib/syntax_tree/node.rb', line 6723 def format(q) q.text("**") q.format(name) if name end |
#pretty_print(q) ⇒ Object
6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 |
# File 'lib/syntax_tree/node.rb', line 6728 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
6739 6740 6741 6742 6743 6744 6745 6746 |
# File 'lib/syntax_tree/node.rb', line 6739 def to_json(*opts) { type: :kwrest_param, name: name, loc: location, cmts: comments }.to_json(*opts) end |