Class: Prism::EmbeddedStatementsNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::EmbeddedStatementsNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents an interpolated set of statements.
"foo #{bar}"
^^^^^^
Instance Attribute Summary collapse
-
#statements ⇒ Object
readonly
attr_reader statements: StatementsNode?.
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].
-
#closing ⇒ Object
def closing: () -> String.
-
#closing_loc ⇒ Object
attr_reader closing_loc: Location.
-
#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, opening_loc: self.opening_loc, statements: self.statements, closing_loc: self.closing_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?statements: StatementsNode?, ?closing_loc: Location) -> EmbeddedStatementsNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, opening_loc: Location, statements: StatementsNode?, closing_loc: Location }.
-
#initialize(source, node_id, location, flags, opening_loc, statements, closing_loc) ⇒ EmbeddedStatementsNode
constructor
Initialize a new EmbeddedStatementsNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#opening ⇒ Object
def opening: () -> String.
-
#opening_loc ⇒ Object
attr_reader opening_loc: Location.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, opening_loc, statements, closing_loc) ⇒ EmbeddedStatementsNode
Initialize a new EmbeddedStatementsNode node.
5559 5560 5561 5562 5563 5564 5565 5566 5567 |
# File 'lib/prism/node.rb', line 5559 def initialize(source, node_id, location, flags, opening_loc, statements, closing_loc) @source = source @node_id = node_id @location = location @flags = flags @opening_loc = opening_loc @statements = statements @closing_loc = closing_loc end |
Instance Attribute Details
#statements ⇒ Object (readonly)
attr_reader statements: StatementsNode?
5612 5613 5614 |
# File 'lib/prism/node.rb', line 5612 def statements @statements end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
5642 5643 5644 |
# File 'lib/prism/node.rb', line 5642 def self.type :embedded_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.
5648 5649 5650 5651 5652 5653 |
# File 'lib/prism/node.rb', line 5648 def ===(other) other.is_a?(EmbeddedStatementsNode) && (opening_loc.nil? == other.opening_loc.nil?) && (statements === other.statements) && (closing_loc.nil? == other.closing_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
5570 5571 5572 |
# File 'lib/prism/node.rb', line 5570 def accept(visitor) visitor.(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
5575 5576 5577 |
# File 'lib/prism/node.rb', line 5575 def child_nodes [statements] end |
#closing ⇒ Object
def closing: () -> String
5627 5628 5629 |
# File 'lib/prism/node.rb', line 5627 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
5615 5616 5617 5618 5619 |
# File 'lib/prism/node.rb', line 5615 def closing_loc location = @closing_loc return location if location.is_a?(Location) @closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
5587 5588 5589 |
# File 'lib/prism/node.rb', line 5587 def comment_targets [opening_loc, *statements, closing_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
5580 5581 5582 5583 5584 |
# File 'lib/prism/node.rb', line 5580 def compact_child_nodes compact = [] #: Array[Prism::node] compact << statements if statements compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, opening_loc: self.opening_loc, statements: self.statements, closing_loc: self.closing_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?statements: StatementsNode?, ?closing_loc: Location) -> EmbeddedStatementsNode
5592 5593 5594 |
# File 'lib/prism/node.rb', line 5592 def copy(node_id: self.node_id, location: self.location, flags: self.flags, opening_loc: self.opening_loc, statements: self.statements, closing_loc: self.closing_loc) EmbeddedStatementsNode.new(source, node_id, location, flags, opening_loc, statements, closing_loc) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, opening_loc: Location, statements: StatementsNode?, closing_loc: Location }
5600 5601 5602 |
# File 'lib/prism/node.rb', line 5600 def deconstruct_keys(keys) { node_id: node_id, location: location, opening_loc: opening_loc, statements: statements, closing_loc: closing_loc } end |
#inspect ⇒ Object
def inspect -> String
5632 5633 5634 |
# File 'lib/prism/node.rb', line 5632 def inspect InspectVisitor.compose(self) end |
#opening ⇒ Object
def opening: () -> String
5622 5623 5624 |
# File 'lib/prism/node.rb', line 5622 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
5605 5606 5607 5608 5609 |
# File 'lib/prism/node.rb', line 5605 def opening_loc location = @opening_loc return location if location.is_a?(Location) @opening_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
5637 5638 5639 |
# File 'lib/prism/node.rb', line 5637 def type :embedded_statements_node end |