Class: Object

Inherits:
BasicObject
Defined in:
lib/types.rb

Instance Method Summary collapse

Instance Method Details

#type_of?(cls) ⇒ Boolean

Indicates object is type of some class. If class isn’t Type, matches against kind_of?.

Returns:



61
62
63
64
65
66
67
68
# File 'lib/types.rb', line 61

def type_of?(cls)
    cls_new = cls::new
    if cls_new.kind_of? Types::Type
        cls_new.match_type? self
    else
        self.kind_of? cls
    end
end

#type_of_any?(classes) ⇒ Boolean

Indicates object is type of some class in the list. If class isn’t Type, matches against kind_of?.

Returns:



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/types.rb', line 76

def type_of_any?(classes)
    if not classes.kind_of? Array
        raise Exception::new("Array expected.")
    end
    
    classes.each do |cls|
        if self.type_of? cls
            return true
        end
    end
    
    return false
end