Class: BuiltinFunctions

Inherits:
Object
  • Object
show all
Defined in:
lib/cli.rb

Instance Method Summary collapse

Instance Method Details

#builtin_import(package) ⇒ Object



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/cli.rb', line 355

def builtin_import(package)
  attributes = {}
  require(package)
  for item in ObjectSpace.each_object
    begin
      item_name = String(item).downcase
    rescue Exception
      next
    end
    if package == item_name
      begin
        scope = Kernel.const_get(item)
      rescue Exception
        next
      end
      for name in scope.constants
        attributes[String(name)] = scope.const_get(name)
      end
    end
  end
  return attributes
end