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



4207
4208
4209
4210
4211
4212
4213
4214
# File 'lib/yarp/node.rb', line 4207

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



4198
4199
4200
# File 'lib/yarp/node.rb', line 4198

def constant_path
  @constant_path
end

#end_keyword_locObject (readonly)

attr_reader end_keyword_loc: Location



4204
4205
4206
# File 'lib/yarp/node.rb', line 4204

def end_keyword_loc
  @end_keyword_loc
end

#localsObject (readonly)

attr_reader locals: Array



4192
4193
4194
# File 'lib/yarp/node.rb', line 4192

def locals
  @locals
end

#module_keyword_locObject (readonly)

attr_reader module_keyword_loc: Location



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

def module_keyword_loc
  @module_keyword_loc
end

#statementsObject (readonly)

attr_reader statements: Node?



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

def statements
  @statements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4217
4218
4219
# File 'lib/yarp/node.rb', line 4217

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

#child_nodesObject Also known as: deconstruct

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



4222
4223
4224
# File 'lib/yarp/node.rb', line 4222

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]



4230
4231
4232
# File 'lib/yarp/node.rb', line 4230

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



4240
4241
4242
# File 'lib/yarp/node.rb', line 4240

def end_keyword
  end_keyword_loc.slice
end

#module_keywordObject

def module_keyword: () -> String



4235
4236
4237
# File 'lib/yarp/node.rb', line 4235

def module_keyword
  module_keyword_loc.slice
end