class Object

Extension of built-in Object class.

Public Instance Methods

type_of?(cls) click to toggle source

Indicates object is type of some class. If class isn't {Types::Type Type}, matches against #kind_of?.

@param [Types::Type, Class] cls some type or class specification @return [Boolean] true if it is, false in otherwise

# File lib/types.rb, line 93
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) click to toggle source

Indicates object is type of some class in the list. If class isn't {Types::Type Type}, matches against #kind_of?.

@param [Array] classes array of {Types::Type Type} or Class objects @return [Boolean] true if it is, false in otherwise

# File lib/types.rb, line 110
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