Module: Tango::Kernel

Defined in:
lib/tango/kernel.rb

Class Method Summary collapse

Class Method Details

.module_classes(mod) ⇒ Array

Fetch list of first level classes in module

Parameters:

  • mod (Module)

Returns:

  • (Array)


9
10
11
12
13
14
15
16
17
# File 'lib/tango/kernel.rb', line 9

def self.module_classes( mod )

  mod.constants.map { |s|
    mod.const_get( s )
  }.select { |c|  
    Class === c
  }

end

.symbolize(klass) ⇒ Symbol

Obtain symbol of a class

Examples:

Tango::Kernel.symblize( A::B::SuperKlass ) #=> :super_klass

Parameters:

  • klass (Class)

Returns:

  • (Symbol)


25
26
27
# File 'lib/tango/kernel.rb', line 25

def self.symbolize( klass )
  klass.to_s.split( '::' ).last.gsub( /(.)([A-Z])/ ,'\1_\2' ).downcase.to_sym
end