Class: YARP::BlockNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::BlockNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a block of ruby code.
[1, 2, 3].each { |i| puts x }
^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location.
-
#locals ⇒ Object
readonly
attr_reader locals: Array.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location.
-
#parameters ⇒ Object
readonly
attr_reader parameters: Node?.
-
#statements ⇒ Object
readonly
attr_reader statements: Node?.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#closing ⇒ Object
def closing: () -> String.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(locals, parameters, statements, opening_loc, closing_loc, location) ⇒ BlockNode
constructor
def initialize: (locals: Array, parameters: Node?, statements: Node?, opening_loc: Location, closing_loc: Location, location: Location) -> void.
-
#opening ⇒ Object
def opening: () -> String.
Constructor Details
#initialize(locals, parameters, statements, opening_loc, closing_loc, location) ⇒ BlockNode
def initialize: (locals: Array, parameters: Node?, statements: Node?, opening_loc: Location, closing_loc: Location, location: Location) -> void
566 567 568 569 570 571 572 573 |
# File 'lib/yarp/node.rb', line 566 def initialize(locals, parameters, statements, opening_loc, closing_loc, location) @locals = locals @parameters = parameters @statements = statements @opening_loc = opening_loc @closing_loc = closing_loc @location = location end |
Instance Attribute Details
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location
563 564 565 |
# File 'lib/yarp/node.rb', line 563 def closing_loc @closing_loc end |
#locals ⇒ Object (readonly)
attr_reader locals: Array
551 552 553 |
# File 'lib/yarp/node.rb', line 551 def locals @locals end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
560 561 562 |
# File 'lib/yarp/node.rb', line 560 def opening_loc @opening_loc end |
#parameters ⇒ Object (readonly)
attr_reader parameters: Node?
554 555 556 |
# File 'lib/yarp/node.rb', line 554 def parameters @parameters end |
#statements ⇒ Object (readonly)
attr_reader statements: Node?
557 558 559 |
# File 'lib/yarp/node.rb', line 557 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
576 577 578 |
# File 'lib/yarp/node.rb', line 576 def accept(visitor) visitor.visit_block_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
582 583 584 |
# File 'lib/yarp/node.rb', line 582 def child_nodes [parameters, statements] end |
#closing ⇒ Object
def closing: () -> String
600 601 602 |
# File 'lib/yarp/node.rb', line 600 def closing closing_loc.slice end |
#deconstruct_keys(keys) ⇒ Object
590 591 592 |
# File 'lib/yarp/node.rb', line 590 def deconstruct_keys(keys) { locals: locals, parameters: parameters, statements: statements, opening_loc: opening_loc, closing_loc: closing_loc, location: location } end |
#opening ⇒ Object
def opening: () -> String
595 596 597 |
# File 'lib/yarp/node.rb', line 595 def opening opening_loc.slice end |