Class: YARP::NoKeywordsParameterNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents the use of ‘**nil` inside method arguments.

def a(**nil)
      ^^^^^
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operator_loc, keyword_loc, location) ⇒ NoKeywordsParameterNode

def initialize: (operator_loc: Location, keyword_loc: Location, location: Location) -> void



7474
7475
7476
7477
7478
# File 'lib/yarp/node.rb', line 7474

def initialize(operator_loc, keyword_loc, location)
  @operator_loc = operator_loc
  @keyword_loc = keyword_loc
  @location = location
end

Instance Attribute Details

#keyword_locObject (readonly)

attr_reader keyword_loc: Location



7471
7472
7473
# File 'lib/yarp/node.rb', line 7471

def keyword_loc
  @keyword_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



7468
7469
7470
# File 'lib/yarp/node.rb', line 7468

def operator_loc
  @operator_loc
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



7481
7482
7483
# File 'lib/yarp/node.rb', line 7481

def accept(visitor)
  visitor.visit_no_keywords_parameter_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



7486
7487
7488
# File 'lib/yarp/node.rb', line 7486

def child_nodes
  []
end

#comment_targetsObject

def comment_targets: () -> Array[Node | Location]



7491
7492
7493
# File 'lib/yarp/node.rb', line 7491

def comment_targets
  [operator_loc, keyword_loc]
end

#copy(**params) ⇒ Object

def copy: (**params) -> NoKeywordsParameterNode



7496
7497
7498
7499
7500
7501
7502
# File 'lib/yarp/node.rb', line 7496

def copy(**params)
  NoKeywordsParameterNode.new(
    params.fetch(:operator_loc) { operator_loc },
    params.fetch(:keyword_loc) { keyword_loc },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



7508
7509
7510
# File 'lib/yarp/node.rb', line 7508

def deconstruct_keys(keys)
  { operator_loc: operator_loc, keyword_loc: keyword_loc, location: location }
end

#inspect(inspector = NodeInspector.new) ⇒ Object



7522
7523
7524
7525
7526
7527
# File 'lib/yarp/node.rb', line 7522

def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
  inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n"
  inspector.to_str
end

#keywordObject

def keyword: () -> String



7518
7519
7520
# File 'lib/yarp/node.rb', line 7518

def keyword
  keyword_loc.slice
end

#operatorObject

def operator: () -> String



7513
7514
7515
# File 'lib/yarp/node.rb', line 7513

def operator
  operator_loc.slice
end