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.
6868
6869
6870
6871
6872
|
# File 'lib/syntax_tree/node.rb', line 6868
def initialize(name:, location:)
@name = name
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6866
6867
6868
|
# File 'lib/syntax_tree/node.rb', line 6866
def
@comments
end
|
#name ⇒ Object
- nil | Ident
-
the name of the parameter
6863
6864
6865
|
# File 'lib/syntax_tree/node.rb', line 6863
def name
@name
end
|
Instance Method Details
#===(other) ⇒ Object
6904
6905
6906
|
# File 'lib/syntax_tree/node.rb', line 6904
def ===(other)
other.is_a?(KwRestParam) && name === other.name
end
|
#accept(visitor) ⇒ Object
6874
6875
6876
|
# File 'lib/syntax_tree/node.rb', line 6874
def accept(visitor)
visitor.visit_kwrest_param(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
6878
6879
6880
|
# File 'lib/syntax_tree/node.rb', line 6878
def child_nodes
[name]
end
|
#copy(name: nil, location: nil) ⇒ Object
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
|
# File 'lib/syntax_tree/node.rb', line 6882
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
6895
6896
6897
|
# File 'lib/syntax_tree/node.rb', line 6895
def deconstruct_keys(_keys)
{ name: name, location: location, comments: }
end
|
6899
6900
6901
6902
|
# File 'lib/syntax_tree/node.rb', line 6899
def format(q)
q.text("**")
q.format(name) if name
end
|