Class: YARP::KeywordRestParameterNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::KeywordRestParameterNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a keyword rest parameter to a method, block, or lambda definition.
def a(**b)
^^^
end
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol?.
-
#name_loc ⇒ Object
readonly
attr_reader name_loc: Location?.
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#copy(**params) ⇒ Object
def copy: (**params) -> KeywordRestParameterNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, name_loc, operator_loc, location) ⇒ KeywordRestParameterNode
constructor
def initialize: (name: Symbol?, name_loc: Location?, operator_loc: Location, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(name, name_loc, operator_loc, location) ⇒ KeywordRestParameterNode
def initialize: (name: Symbol?, name_loc: Location?, operator_loc: Location, location: Location) -> void
6289 6290 6291 6292 6293 6294 |
# File 'lib/yarp/node.rb', line 6289 def initialize(name, name_loc, operator_loc, location) @name = name @name_loc = name_loc @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol?
6280 6281 6282 |
# File 'lib/yarp/node.rb', line 6280 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location?
6283 6284 6285 |
# File 'lib/yarp/node.rb', line 6283 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
6286 6287 6288 |
# File 'lib/yarp/node.rb', line 6286 def operator_loc @operator_loc end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
6297 6298 6299 |
# File 'lib/yarp/node.rb', line 6297 def accept(visitor) visitor.visit_keyword_rest_parameter_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
6302 6303 6304 |
# File 'lib/yarp/node.rb', line 6302 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
6307 6308 6309 |
# File 'lib/yarp/node.rb', line 6307 def comment_targets [*name_loc, operator_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> KeywordRestParameterNode
6312 6313 6314 6315 6316 6317 6318 6319 |
# File 'lib/yarp/node.rb', line 6312 def copy(**params) KeywordRestParameterNode.new( params.fetch(:name) { name }, params.fetch(:name_loc) { name_loc }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
6325 6326 6327 |
# File 'lib/yarp/node.rb', line 6325 def deconstruct_keys(keys) { name: name, name_loc: name_loc, operator_loc: operator_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
6334 6335 6336 6337 6338 6339 6340 |
# File 'lib/yarp/node.rb', line 6334 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── name: #{name.inspect}\n" inspector << "├── name_loc: #{inspector.location(name_loc)}\n" inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n" inspector.to_str end |
#operator ⇒ Object
def operator: () -> String
6330 6331 6332 |
# File 'lib/yarp/node.rb', line 6330 def operator operator_loc.slice end |