Class: ASTModule

Inherits:
ASTEntity show all
Defined in:
lib/ripper/extract_constants.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ASTEntity

inherited, load, node_classes, node_classes_cache, node_for

Constructor Details

#initialize(*args) ⇒ ASTModule

Returns a new instance of ASTModule.



285
286
287
288
289
290
# File 'lib/ripper/extract_constants.rb', line 285

def initialize(*args)
  @module_name = args.find{|a| a.first == :const_ref}.last[1]
  @body = args.find{|a| a.first == :bodystmt}[1].map{|node|
    ASTEntity.node_for(node)
  }
end

Class Method Details

.ripper_idObject



284
# File 'lib/ripper/extract_constants.rb', line 284

def self.ripper_id; :module end

Instance Method Details

#collect_constants(result, context) ⇒ Object



291
292
293
294
295
296
# File 'lib/ripper/extract_constants.rb', line 291

def collect_constants(result, context)
  result.declare_const(@module_name)
  result = result.nest(@module_name)
  context.module << @module_name
  super(result, context)
end