Class: YARP::AssocSplatNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::AssocSplatNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a splat in a hash literal.
{ **foo }
^^^^^
Instance Attribute Summary collapse
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#value ⇒ Object
readonly
attr_reader value: Node?.
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) -> AssocSplatNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(value, operator_loc, location) ⇒ AssocSplatNode
constructor
def initialize: (value: Node?, operator_loc: Location, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(value, operator_loc, location) ⇒ AssocSplatNode
def initialize: (value: Node?, operator_loc: Location, location: Location) -> void
550 551 552 553 554 |
# File 'lib/yarp/node.rb', line 550 def initialize(value, operator_loc, location) @value = value @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
547 548 549 |
# File 'lib/yarp/node.rb', line 547 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node?
544 545 546 |
# File 'lib/yarp/node.rb', line 544 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
557 558 559 |
# File 'lib/yarp/node.rb', line 557 def accept(visitor) visitor.visit_assoc_splat_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
562 563 564 |
# File 'lib/yarp/node.rb', line 562 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
567 568 569 |
# File 'lib/yarp/node.rb', line 567 def comment_targets [*value, operator_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> AssocSplatNode
572 573 574 575 576 577 578 |
# File 'lib/yarp/node.rb', line 572 def copy(**params) AssocSplatNode.new( params.fetch(:value) { value }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
584 585 586 |
# File 'lib/yarp/node.rb', line 584 def deconstruct_keys(keys) { value: value, operator_loc: operator_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
593 594 595 596 597 598 599 600 601 602 603 |
# File 'lib/yarp/node.rb', line 593 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) if (value = self.value).nil? inspector << "├── value: ∅\n" else inspector << "├── value:\n" inspector << value.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n" inspector.to_str end |
#operator ⇒ Object
def operator: () -> String
589 590 591 |
# File 'lib/yarp/node.rb', line 589 def operator operator_loc.slice end |