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; bar; 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
-
#each_child_node ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator.
-
#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.
18031 18032 18033 18034 18035 18036 18037 |
# File 'lib/prism/node.rb', line 18031 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
18080 18081 18082 |
# File 'lib/prism/node.rb', line 18080 def body @body end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See Node::type.
18093 18094 18095 |
# File 'lib/prism/node.rb', line 18093 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.
18099 18100 18101 18102 18103 |
# File 'lib/prism/node.rb', line 18099 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
18040 18041 18042 |
# File 'lib/prism/node.rb', line 18040 def accept(visitor) visitor.visit_statements_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
18045 18046 18047 |
# File 'lib/prism/node.rb', line 18045 def child_nodes [*body] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
18062 18063 18064 |
# File 'lib/prism/node.rb', line 18062 def comment_targets [*body] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
18057 18058 18059 |
# File 'lib/prism/node.rb', line 18057 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
18067 18068 18069 |
# File 'lib/prism/node.rb', line 18067 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
18075 18076 18077 |
# File 'lib/prism/node.rb', line 18075 def deconstruct_keys(keys) { node_id: node_id, location: location, body: body } end |
#each_child_node ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator
18050 18051 18052 18053 18054 |
# File 'lib/prism/node.rb', line 18050 def each_child_node return to_enum(:each_child_node) unless block_given? body.each { |node| yield node } end |
#inspect ⇒ Object
def inspect -> String
18083 18084 18085 |
# File 'lib/prism/node.rb', line 18083 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
18088 18089 18090 |
# File 'lib/prism/node.rb', line 18088 def type :statements_node end |