Class: Prism::StatementsNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::StatementsNode
- Defined in:
- lib/prism/node.rb,
ext/prism/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.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, body: self.body) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Array) -> StatementsNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(source, node_id, location, flags, body) ⇒ StatementsNode
constructor
Initialize a new StatementsNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, body) ⇒ StatementsNode
Initialize a new StatementsNode node.
17006 17007 17008 17009 17010 17011 17012 |
# File 'lib/prism/node.rb', line 17006 def initialize(source, node_id, location, flags, body) @source = source @node_id = node_id @location = location @flags = flags @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
attr_reader body: Array
17048 17049 17050 |
# File 'lib/prism/node.rb', line 17048 def body @body end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
17061 17062 17063 |
# File 'lib/prism/node.rb', line 17061 def self.type :statements_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
17067 17068 17069 17070 17071 |
# File 'lib/prism/node.rb', line 17067 def ===(other) other.is_a?(StatementsNode) && (body.length == other.body.length) && body.zip(other.body).all? { |left, right| left === right } end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
17015 17016 17017 |
# File 'lib/prism/node.rb', line 17015 def accept(visitor) visitor.visit_statements_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
17020 17021 17022 |
# File 'lib/prism/node.rb', line 17020 def child_nodes [*body] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
17030 17031 17032 |
# File 'lib/prism/node.rb', line 17030 def comment_targets [*body] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
17025 17026 17027 |
# File 'lib/prism/node.rb', line 17025 def compact_child_nodes [*body] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, body: self.body) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Array) -> StatementsNode
17035 17036 17037 |
# File 'lib/prism/node.rb', line 17035 def copy(node_id: self.node_id, location: self.location, flags: self.flags, body: self.body) StatementsNode.new(source, node_id, location, flags, body) end |
#deconstruct_keys(keys) ⇒ Object
17043 17044 17045 |
# File 'lib/prism/node.rb', line 17043 def deconstruct_keys(keys) { node_id: node_id, location: location, body: body } end |
#inspect ⇒ Object
def inspect -> String
17051 17052 17053 |
# File 'lib/prism/node.rb', line 17051 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
17056 17057 17058 |
# File 'lib/prism/node.rb', line 17056 def type :statements_node end |