Class: SyntaxTree::KwRestParam
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::KwRestParam
show all
- Defined in:
- lib/syntax_tree/node.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
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(name:, location:) ⇒ KwRestParam
Returns a new instance of KwRestParam.
6877
6878
6879
6880
6881
|
# File 'lib/syntax_tree/node.rb', line 6877
def initialize(name:, location:)
@name = name
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6875
6876
6877
|
# File 'lib/syntax_tree/node.rb', line 6875
def
@comments
end
|
#name ⇒ Object
- nil | Ident
-
the name of the parameter
6872
6873
6874
|
# File 'lib/syntax_tree/node.rb', line 6872
def name
@name
end
|
Instance Method Details
#===(other) ⇒ Object
6913
6914
6915
|
# File 'lib/syntax_tree/node.rb', line 6913
def ===(other)
other.is_a?(KwRestParam) && name === other.name
end
|
#accept(visitor) ⇒ Object
6883
6884
6885
|
# File 'lib/syntax_tree/node.rb', line 6883
def accept(visitor)
visitor.visit_kwrest_param(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
6887
6888
6889
|
# File 'lib/syntax_tree/node.rb', line 6887
def child_nodes
[name]
end
|
#copy(name: nil, location: nil) ⇒ Object
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
|
# File 'lib/syntax_tree/node.rb', line 6891
def copy(name: nil, location: nil)
node =
KwRestParam.new(
name: name || self.name,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
6904
6905
6906
|
# File 'lib/syntax_tree/node.rb', line 6904
def deconstruct_keys(_keys)
{ name: name, location: location, comments: }
end
|
6908
6909
6910
6911
|
# File 'lib/syntax_tree/node.rb', line 6908
def format(q)
q.text("**")
q.format(name) if name
end
|