Class: Filigree::InstancePattern
- Inherits:
-
SingleObjectPattern
- Object
- BasicPattern
- SingleObjectPattern
- Filigree::InstancePattern
- Defined in:
- lib/filigree/match.rb
Overview
A pattern for checking to see if an object is an instance of a given class.
Instance Attribute Summary
Attributes inherited from SingleObjectPattern
Instance Method Summary collapse
-
#<=>(other) ⇒ -1, ...
Specialized version of the bi-directional comparison operator.
-
#match?(object, _) ⇒ Boolean
Test the object to see if the object is an instance of the given class.
- #weight ⇒ Object
Methods inherited from SingleObjectPattern
Methods included from AbstractClass
#abstract_method, extended, #install_icvars, #new
Methods inherited from BasicPattern
Constructor Details
This class inherits a constructor from Filigree::SingleObjectPattern
Instance Method Details
#<=>(other) ⇒ -1, ...
Specialized version of the bi-directional comparison operator.
359 360 361 362 363 364 365 366 367 368 |
# File 'lib/filigree/match.rb', line 359 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, _) ⇒ Boolean
Test the object to see if the object is an instance of the given class.
376 377 378 |
# File 'lib/filigree/match.rb', line 376 def match?(object, _) object.is_a?(@pattern_elem) end |
#weight ⇒ Object
380 381 382 |
# File 'lib/filigree/match.rb', line 380 def weight 3 end |