Class: Class

Inherits
Object show all
Defined in
lib/kyanite/general/classutils.rb

Class Utils

Kyanite definitions

Class, Symbol, String

Kyanite tests and examples

TestKyaniteClassutils

Usage

require 'kyanite/general/classutils'

Added from Facets Class:

descendants(generations=-1))

List all descedents of this class.

Class Utils (collapse)

Instance Method Details

- (Integer) <=>(other)

Comparison operator (alphabetical)

Returns:



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)

Returns:

  • (Boolean)


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