Class: YARP::EmbeddedStatementsNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents an interpolated set of statements.

"foo #{bar}"
     ^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opening_loc, statements, closing_loc, location) ⇒ EmbeddedStatementsNode

def initialize: (opening_loc: Location, statements: Node?, closing_loc: Location, location: Location) -> void



2108
2109
2110
2111
2112
2113
# File 'lib/yarp/node.rb', line 2108

def initialize(opening_loc, statements, closing_loc, location)
  @opening_loc = opening_loc
  @statements = statements
  @closing_loc = closing_loc
  @location = location
end

Instance Attribute Details

#closing_locObject (readonly)

attr_reader closing_loc: Location



2105
2106
2107
# File 'lib/yarp/node.rb', line 2105

def closing_loc
  @closing_loc
end

#opening_locObject (readonly)

attr_reader opening_loc: Location



2099
2100
2101
# File 'lib/yarp/node.rb', line 2099

def opening_loc
  @opening_loc
end

#statementsObject (readonly)

attr_reader statements: Node?



2102
2103
2104
# File 'lib/yarp/node.rb', line 2102

def statements
  @statements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



2116
2117
2118
# File 'lib/yarp/node.rb', line 2116

def accept(visitor)
  visitor.visit_embedded_statements_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



2121
2122
2123
# File 'lib/yarp/node.rb', line 2121

def child_nodes
  [statements]
end

#closingObject

def closing: () -> String



2139
2140
2141
# File 'lib/yarp/node.rb', line 2139

def closing
  closing_loc.slice
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



2129
2130
2131
# File 'lib/yarp/node.rb', line 2129

def deconstruct_keys(keys)
  { opening_loc: opening_loc, statements: statements, closing_loc: closing_loc, location: location }
end

#openingObject

def opening: () -> String



2134
2135
2136
# File 'lib/yarp/node.rb', line 2134

def opening
  opening_loc.slice
end