Class: YARP::StatementsNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::StatementsNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a set of statements contained within some scope.
foo; ; baz
^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
attr_reader body: Array.
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) -> StatementsNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(body, location) ⇒ StatementsNode
constructor
def initialize: (body: Array, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
Constructor Details
#initialize(body, location) ⇒ StatementsNode
def initialize: (body: Array, location: Location) -> void
9498 9499 9500 9501 |
# File 'lib/yarp/node.rb', line 9498 def initialize(body, location) @body = body @location = location end |
Instance Attribute Details
#body ⇒ Object (readonly)
attr_reader body: Array
9495 9496 9497 |
# File 'lib/yarp/node.rb', line 9495 def body @body end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
9504 9505 9506 |
# File 'lib/yarp/node.rb', line 9504 def accept(visitor) visitor.visit_statements_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
9509 9510 9511 |
# File 'lib/yarp/node.rb', line 9509 def child_nodes [*body] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
9514 9515 9516 |
# File 'lib/yarp/node.rb', line 9514 def comment_targets [*body] end |
#copy(**params) ⇒ Object
def copy: (**params) -> StatementsNode
9519 9520 9521 9522 9523 9524 |
# File 'lib/yarp/node.rb', line 9519 def copy(**params) StatementsNode.new( params.fetch(:body) { body }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
9530 9531 9532 |
# File 'lib/yarp/node.rb', line 9530 def deconstruct_keys(keys) { body: body, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
9534 9535 9536 9537 9538 |
# File 'lib/yarp/node.rb', line 9534 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "└── body: #{inspector.list("#{inspector.prefix} ", body)}" inspector.to_str end |