Class: Module

Inherits:
Object show all
Defined in:
lib/extra/module.rb

Instance Method Summary collapse

Instance Method Details

#classesObject

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_classObject

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