class YARP::FindPatternNode
Represents a find pattern in pattern matching.
foo in *bar, baz, *qux ^^^^^^^^^^^^^^^^^^^^^^ foo in [*bar, baz, *qux] ^^^^^^^^^^^^^^^^^^^^^^^^ foo in Foo(*bar, baz, *qux) ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Attributes
closing_loc[R]
attr_reader closing_loc
: Location
?
constant[R]
attr_reader constant: Node
?
left[R]
attr_reader left: Node
opening_loc[R]
attr_reader opening_loc
: Location
?
requireds[R]
attr_reader requireds: Array
right[R]
attr_reader right: Node
Public Class Methods
new(constant, left, requireds, right, opening_loc, closing_loc, location)
click to toggle source
def initialize: (constant: Node
?, left: Node
, requireds: Array, right: Node
, opening_loc
: Location
?, closing_loc
: Location
?, location: Location
) -> void
# File yarp/node.rb, line 4102 def initialize(constant, left, requireds, right, opening_loc, closing_loc, location) @constant = constant @left = left @requireds = requireds @right = right @opening_loc = opening_loc @closing_loc = closing_loc @location = location end
Public Instance Methods
accept(visitor)
click to toggle source
def accept: (visitor: Visitor
) -> void
# File yarp/node.rb, line 4113 def accept(visitor) visitor.visit_find_pattern_node(self) end
child_nodes()
click to toggle source
def child_nodes
: () -> Array[nil | Node]
# File yarp/node.rb, line 4118 def child_nodes [constant, left, *requireds, right] end
Also aliased as: deconstruct
closing()
click to toggle source
def closing: () -> String?
# File yarp/node.rb, line 4154 def closing closing_loc&.slice end
comment_targets()
click to toggle source
def comment_targets
: () -> Array[Node | Location]
# File yarp/node.rb, line 4123 def comment_targets [*constant, left, *requireds, right, *opening_loc, *closing_loc] end
copy(**params)
click to toggle source
def copy: (**params) -> FindPatternNode
# File yarp/node.rb, line 4128 def copy(**params) FindPatternNode.new( params.fetch(:constant) { constant }, params.fetch(:left) { left }, params.fetch(:requireds) { requireds }, params.fetch(:right) { right }, params.fetch(:opening_loc) { opening_loc }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:location) { location }, ) end
deconstruct_keys(keys)
click to toggle source
def deconstruct_keys
: (keys: Array) -> Hash[Symbol, nil | Node
| Array | String | Token
| Array | Location]
# File yarp/node.rb, line 4144 def deconstruct_keys(keys) { constant: constant, left: left, requireds: requireds, right: right, opening_loc: opening_loc, closing_loc: closing_loc, location: location } end
inspect(inspector = NodeInspector.new)
click to toggle source
# File yarp/node.rb, line 4158 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) if (constant = self.constant).nil? inspector << "├── constant: ∅\n" else inspector << "├── constant:\n" inspector << constant.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end inspector << "├── left:\n" inspector << inspector.child_node(left, "│ ") inspector << "├── requireds: #{inspector.list("#{inspector.prefix}│ ", requireds)}" inspector << "├── right:\n" inspector << inspector.child_node(right, "│ ") inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n" inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n" inspector.to_str end
opening()
click to toggle source
def opening: () -> String?
# File yarp/node.rb, line 4149 def opening opening_loc&.slice end