Class: Class
- Defined in
- lib/kyanite/general/classutils.rb
Class Utils
- Kyanite tests and examples
- Usage
-
require 'kyanite/general/classutils'
Added from Facets Class:
- descendants(generations=-1))
-
List all descedents of this class.
Class Utils (collapse)
-
- (Integer) <=>(other)
Comparison operator (alphabetical).
-
- (Boolean) =~(other)
Fuzzy comparison of two classes (useful for tests).
- - (Object) to_class
- - (Object) to_classname
Instance Method Details
- (Integer) <=>(other)
Comparison operator (alphabetical)
25 26 27 |
# File 'lib/kyanite/general/classutils.rb', line 25 def <=>(other) ( ( self.to_s ) <=> ( other.to_s ) ) end |
- (Boolean) =~(other)
Fuzzy comparison of two classes (useful for tests)
32 33 34 35 36 37 |
# File 'lib/kyanite/general/classutils.rb', line 32 def =~(other) return true if self == other return true if self.descendants.include?(other) return true if other.descendants.include?(self) return false end |
- (Object) to_class
40 41 42 |
# File 'lib/kyanite/general/classutils.rb', line 40 def to_class self end |
- (Object) to_classname
46 47 48 |
# File 'lib/kyanite/general/classutils.rb', line 46 def to_classname self.to_s.demodulize.underscore end |