Class: YARP::StatementsNode

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

Overview

Represents a set of statements contained within some scope.

foo; bar; baz
^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, location) ⇒ StatementsNode

def initialize: (body: Array, location: Location) -> void



7143
7144
7145
7146
# File 'lib/yarp/node.rb', line 7143

def initialize(body, location)
  @body = body
  @location = location
end

Instance Attribute Details

#bodyObject (readonly)

attr_reader body: Array



7140
7141
7142
# File 'lib/yarp/node.rb', line 7140

def body
  @body
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



7149
7150
7151
# File 'lib/yarp/node.rb', line 7149

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

#child_nodesObject Also known as: deconstruct

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



7154
7155
7156
# File 'lib/yarp/node.rb', line 7154

def child_nodes
  [*body]
end

#copy(**params) ⇒ Object

def copy: (**params) -> StatementsNode



7159
7160
7161
7162
7163
7164
# File 'lib/yarp/node.rb', line 7159

def copy(**params)
  StatementsNode.new(
    params.fetch(:body) { body },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

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



7170
7171
7172
# File 'lib/yarp/node.rb', line 7170

def deconstruct_keys(keys)
  { body: body, location: location }
end