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
-
#body ⇒ Object
readonly
attr_reader body: Node?.
-
#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: BlockParametersNode?.
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.
-
#copy(**params) ⇒ Object
def copy: (**params) -> BlockNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(locals, parameters, body, opening_loc, closing_loc, location) ⇒ BlockNode
constructor
def initialize: (locals: Array, parameters: BlockParametersNode?, body: Node?, opening_loc: Location, closing_loc: Location, location: Location) -> void.
-
#opening ⇒ Object
def opening: () -> String.
Constructor Details
#initialize(locals, parameters, body, opening_loc, closing_loc, location) ⇒ BlockNode
def initialize: (locals: Array, parameters: BlockParametersNode?, body: Node?, opening_loc: Location, closing_loc: Location, location: Location) -> void
665 666 667 668 669 670 671 672 |
# File 'lib/yarp/node.rb', line 665 def initialize(locals, parameters, body, opening_loc, closing_loc, location) @locals = locals @parameters = parameters @body = body @opening_loc = opening_loc @closing_loc = closing_loc @location = location end |
Instance Attribute Details
#body ⇒ Object (readonly)
attr_reader body: Node?
656 657 658 |
# File 'lib/yarp/node.rb', line 656 def body @body end |
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location
662 663 664 |
# File 'lib/yarp/node.rb', line 662 def closing_loc @closing_loc end |
#locals ⇒ Object (readonly)
attr_reader locals: Array
650 651 652 |
# File 'lib/yarp/node.rb', line 650 def locals @locals end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
659 660 661 |
# File 'lib/yarp/node.rb', line 659 def opening_loc @opening_loc end |
#parameters ⇒ Object (readonly)
attr_reader parameters: BlockParametersNode?
653 654 655 |
# File 'lib/yarp/node.rb', line 653 def parameters @parameters end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
675 676 677 |
# File 'lib/yarp/node.rb', line 675 def accept(visitor) visitor.visit_block_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
680 681 682 |
# File 'lib/yarp/node.rb', line 680 def child_nodes [parameters, body] end |
#closing ⇒ Object
def closing: () -> String
710 711 712 |
# File 'lib/yarp/node.rb', line 710 def closing closing_loc.slice end |
#copy(**params) ⇒ Object
def copy: (**params) -> BlockNode
685 686 687 688 689 690 691 692 693 694 |
# File 'lib/yarp/node.rb', line 685 def copy(**params) BlockNode.new( params.fetch(:locals) { locals }, params.fetch(:parameters) { parameters }, params.fetch(:body) { body }, params.fetch(:opening_loc) { opening_loc }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
700 701 702 |
# File 'lib/yarp/node.rb', line 700 def deconstruct_keys(keys) { locals: locals, parameters: parameters, body: body, opening_loc: opening_loc, closing_loc: closing_loc, location: location } end |
#opening ⇒ Object
def opening: () -> String
705 706 707 |
# File 'lib/yarp/node.rb', line 705 def opening opening_loc.slice end |