Class: YARP::BlockArgumentNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::BlockArgumentNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents block method arguments.
bar(&args)
^^^^^^^^^^
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
attr_reader expression: Node?.
-
#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) -> BlockArgumentNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(expression, operator_loc, location) ⇒ BlockArgumentNode
constructor
def initialize: (expression: Node?, operator_loc: Location, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(expression, operator_loc, location) ⇒ BlockArgumentNode
def initialize: (expression: Node?, operator_loc: Location, location: Location) -> void
782 783 784 785 786 |
# File 'lib/yarp/node.rb', line 782 def initialize(expression, operator_loc, location) @expression = expression @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#expression ⇒ Object (readonly)
attr_reader expression: Node?
776 777 778 |
# File 'lib/yarp/node.rb', line 776 def expression @expression end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
779 780 781 |
# File 'lib/yarp/node.rb', line 779 def operator_loc @operator_loc end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
789 790 791 |
# File 'lib/yarp/node.rb', line 789 def accept(visitor) visitor.visit_block_argument_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
794 795 796 |
# File 'lib/yarp/node.rb', line 794 def child_nodes [expression] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
799 800 801 |
# File 'lib/yarp/node.rb', line 799 def comment_targets [*expression, operator_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> BlockArgumentNode
804 805 806 807 808 809 810 |
# File 'lib/yarp/node.rb', line 804 def copy(**params) BlockArgumentNode.new( params.fetch(:expression) { expression }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
816 817 818 |
# File 'lib/yarp/node.rb', line 816 def deconstruct_keys(keys) { expression: expression, operator_loc: operator_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
825 826 827 828 829 830 831 832 833 834 835 |
# File 'lib/yarp/node.rb', line 825 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) if (expression = self.expression).nil? inspector << "├── expression: ∅\n" else inspector << "├── expression:\n" inspector << expression.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
821 822 823 |
# File 'lib/yarp/node.rb', line 821 def operator operator_loc.slice end |