class Filigree::InstancePattern

A pattern for checking to see if an object is an instance of a given class.

Public Instance Methods

<=>(other) click to toggle source

Specialized version of the bi-directional comparison operator.

@param [BasicPattern] other Right-hand side of the comparison

@return [-1, 0, 1] Value corresponding to less than, equal to, or

greater than the right-hand side pattern.
Calls superclass method Filigree::BasicPattern#<=>
# File lib/filigree/match.rb, line 357
def <=>(other)
        if other.is_a?(InstancePattern)
                if    self.pattern_elem == other.pattern_elem            then 0
                elsif self.pattern_elem.subclass_of?(other.pattern_elem) then 1
                else                                                         -1
                end
        else
                super(other)
        end
end
match?(object, _) click to toggle source

Test the object to see if the object is an instance of the given class.

@param [Object] object Object to test pattern against

@return [Boolean]

# File lib/filigree/match.rb, line 374
def match?(object, _)
        object.is_a?(@pattern_elem)
end
weight() click to toggle source
# File lib/filigree/match.rb, line 378
def weight
        3
end