Class: Prism::ParametersNode
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Node
|
|
Instance Chain:
self,
Node
|
|
Inherits: |
Prism::Node
|
Defined in: | lib/prism/node_ext.rb |
Instance Method Summary
-
#signature
Mirrors the
Method#parameters
method.
Instance Method Details
#signature
Mirrors the Method#parameters
method.
# File 'lib/prism/node_ext.rb', line 149
def signature names = [] requireds.each do |param| names << (param.is_a?(MultiTargetNode) ? [:req] : [:req, param.name]) end optionals.each { |param| names << [:opt, param.name] } names << [:rest, rest.name || :*] if rest posts.each do |param| names << (param.is_a?(MultiTargetNode) ? [:req] : [:req, param.name]) end # Regardless of the order in which the keywords were defined, the required # keywords always come first followed by the optional keywords. keyopt = [] keywords.each do |param| if param.is_a?(OptionalKeywordParameterNode) keyopt << param else names << [:keyreq, param.name] end end keyopt.each { |param| names << [:key, param.name] } case keyword_rest when ForwardingParameterNode names.concat([[:rest, :*], [:keyrest, :**], [:block, :&]]) when KeywordRestParameterNode names << [:keyrest, keyword_rest.name || :**] when NoKeywordsParameterNode names << [:nokey] end names << [:block, block.name || :&] if block names end