Class: YARP::ModuleNode

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

Overview

Represents a module declaration involving the ‘module` keyword.

module Foo end
^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locals, module_keyword_loc, constant_path, statements, end_keyword_loc, location) ⇒ ModuleNode

def initialize: (locals: Array, module_keyword_loc: Location, constant_path: Node, statements: Node?, end_keyword_loc: Location, location: Location) -> void



4178
4179
4180
4181
4182
4183
4184
4185
# File 'lib/yarp/node.rb', line 4178

def initialize(locals, module_keyword_loc, constant_path, statements, end_keyword_loc, location)
  @locals = locals
  @module_keyword_loc = module_keyword_loc
  @constant_path = constant_path
  @statements = statements
  @end_keyword_loc = end_keyword_loc
  @location = location
end

Instance Attribute Details

#constant_pathObject (readonly)

attr_reader constant_path: Node



4169
4170
4171
# File 'lib/yarp/node.rb', line 4169

def constant_path
  @constant_path
end

#end_keyword_locObject (readonly)

attr_reader end_keyword_loc: Location



4175
4176
4177
# File 'lib/yarp/node.rb', line 4175

def end_keyword_loc
  @end_keyword_loc
end

#localsObject (readonly)

attr_reader locals: Array



4163
4164
4165
# File 'lib/yarp/node.rb', line 4163

def locals
  @locals
end

#module_keyword_locObject (readonly)

attr_reader module_keyword_loc: Location



4166
4167
4168
# File 'lib/yarp/node.rb', line 4166

def module_keyword_loc
  @module_keyword_loc
end

#statementsObject (readonly)

attr_reader statements: Node?



4172
4173
4174
# File 'lib/yarp/node.rb', line 4172

def statements
  @statements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4188
4189
4190
# File 'lib/yarp/node.rb', line 4188

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

#child_nodesObject Also known as: deconstruct

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



4194
4195
4196
# File 'lib/yarp/node.rb', line 4194

def child_nodes
  [constant_path, statements]
end

#deconstruct_keys(keys) ⇒ Object

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



4202
4203
4204
# File 'lib/yarp/node.rb', line 4202

def deconstruct_keys(keys)
  { locals: locals, module_keyword_loc: module_keyword_loc, constant_path: constant_path, statements: statements, end_keyword_loc: end_keyword_loc, location: location }
end

#end_keywordObject

def end_keyword: () -> String



4212
4213
4214
# File 'lib/yarp/node.rb', line 4212

def end_keyword
  end_keyword_loc.slice
end

#module_keywordObject

def module_keyword: () -> String



4207
4208
4209
# File 'lib/yarp/node.rb', line 4207

def module_keyword
  module_keyword_loc.slice
end