Class: ASTConst

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) ⇒ ASTConst

Returns a new instance of ASTConst.



260
261
262
# File 'lib/ripper/extract_constants.rb', line 260

def initialize(*args)
  @const_name = args[0]
end

Class Method Details

.ripper_idObject



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

def self.ripper_id; :'@const' end

Instance Method Details

#collect_constants(result, context) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/ripper/extract_constants.rb', line 263

def collect_constants(result, context)
  return super(result, context)  if context[:stop_collect_constants]
  if context[:variable_assignment]
    result.declare_const(@const_name)
  else
    analyze_const = context[:analyze_const].nil? ? true  : context[:analyze_const]
    if context[:top]
      result.use_const('::'+@const_name)
    else
      result.use_const(@const_name, analyze_const)
    end

  end

  super(result, context)
end