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



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

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



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

def closing_loc
  @closing_loc
end

#opening_locObject (readonly)

attr_reader opening_loc: Location



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

def opening_loc
  @opening_loc
end

#statementsObject (readonly)

attr_reader statements: Node?



2131
2132
2133
# File 'lib/yarp/node.rb', line 2131

def statements
  @statements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



2145
2146
2147
# File 'lib/yarp/node.rb', line 2145

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

#child_nodesObject Also known as: deconstruct

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



2151
2152
2153
# File 'lib/yarp/node.rb', line 2151

def child_nodes
  [statements]
end

#closingObject

def closing: () -> String



2169
2170
2171
# File 'lib/yarp/node.rb', line 2169

def closing
  closing_loc.slice
end

#deconstruct_keys(keys) ⇒ Object

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



2159
2160
2161
# File 'lib/yarp/node.rb', line 2159

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

#openingObject

def opening: () -> String



2164
2165
2166
# File 'lib/yarp/node.rb', line 2164

def opening
  opening_loc.slice
end