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[nil | Node].
-
#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.
16798 16799 16800 16801 16802 16803 16804 |
# File 'lib/prism/node.rb', line 16798 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
16840 16841 16842 |
# File 'lib/prism/node.rb', line 16840 def body @body end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
16853 16854 16855 |
# File 'lib/prism/node.rb', line 16853 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.
16859 16860 16861 16862 16863 |
# File 'lib/prism/node.rb', line 16859 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
16807 16808 16809 |
# File 'lib/prism/node.rb', line 16807 def accept(visitor) visitor.visit_statements_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
16812 16813 16814 |
# File 'lib/prism/node.rb', line 16812 def child_nodes [*body] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
16822 16823 16824 |
# File 'lib/prism/node.rb', line 16822 def comment_targets [*body] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
16817 16818 16819 |
# File 'lib/prism/node.rb', line 16817 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
16827 16828 16829 |
# File 'lib/prism/node.rb', line 16827 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
16835 16836 16837 |
# File 'lib/prism/node.rb', line 16835 def deconstruct_keys(keys) { node_id: node_id, location: location, body: body } end |
#inspect ⇒ Object
def inspect -> String
16843 16844 16845 |
# File 'lib/prism/node.rb', line 16843 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
16848 16849 16850 |
# File 'lib/prism/node.rb', line 16848 def type :statements_node end |