Class: Module
Instance Method Summary collapse
-
#classes ⇒ Object
List classes within a module.
-
#each_class ⇒ Object
Go through each defined class in the module.
Instance Method Details
#classes ⇒ Object
List classes within a module. Thanks to apeiros for this.
Example: Class.classes #=> [TrueClass, FalseClass, NilClass, Class]
Returns: Array
17 18 19 20 21 22 23 |
# File 'lib/extra/module.rb', line 17 def classes list = [] each_class { |class_constant| list << class_constant } return list end |
#each_class ⇒ Object
Go through each defined class in the module. Credit to apeiros for this =)
4 5 6 7 8 9 |
# File 'lib/extra/module.rb', line 4 def each_class constants.each { |constant_name| constant = const_get(constant_name.intern) yield constant if constant.class == Class && constant.name =~ /#{self.name}/ } end |