class YARP::HashPatternNode
^^^^^^^^^^^^^^^^^^^
foo => { a: 1, b: 2, **c }
^^^^^^^^^^^^^^
foo => { a: 1, b: 2 }
Represents a hash pattern in pattern matching.
def accept(visitor)
def accept(visitor) visitor.visit_hash_pattern_node(self) end
def child_nodes
def child_nodes [constant, *assocs, kwrest] end
def closing
def closing closing_loc&.slice end
def comment_targets
def comment_targets [*constant, *assocs, *kwrest, *opening_loc, *closing_loc] end
def copy(**params)
def copy(**params) HashPatternNode.new( params.fetch(:constant) { constant }, params.fetch(:assocs) { assocs }, params.fetch(:kwrest) { kwrest }, params.fetch(:opening_loc) { opening_loc }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:location) { location }, ) end
def deconstruct_keys(keys)
def deconstruct_keys(keys) { constant: constant, assocs: assocs, kwrest: kwrest, opening_loc: opening_loc, closing_loc: closing_loc, location: location } end
def initialize(constant, assocs, kwrest, opening_loc, closing_loc, location)
def initialize(constant, assocs, kwrest, opening_loc, closing_loc, location) @constant = constant @assocs = assocs @kwrest = kwrest @opening_loc = opening_loc @closing_loc = closing_loc @location = location end
def inspect(inspector = NodeInspector.new)
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 << "├── assocs: #{inspector.list("#{inspector.prefix}│ ", assocs)}" if (kwrest = self.kwrest).nil? inspector << "├── kwrest: ∅\n" else inspector << "├── kwrest:\n" inspector << kwrest.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n" inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n" inspector.to_str end
def opening
def opening opening_loc&.slice end