Class: PageMagic::Comparator::Fuzzy
- Inherits:
-
PageMagic::Comparator
- Object
- PageMagic::Comparator
- PageMagic::Comparator::Fuzzy
- Defined in:
- lib/page_magic/comparator/fuzzy.rb
Overview
class Fuzzy - used for modeling and comparing components that are 'fuzzy' i.e. respond to =~
e.g. a Regexp
Instance Attribute Summary
Attributes inherited from PageMagic::Comparator
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(comparator) ⇒ Fuzzy
constructor
A new instance of Fuzzy.
- #match?(value) ⇒ Boolean
Methods inherited from PageMagic::Comparator
Constructor Details
#initialize(comparator) ⇒ Fuzzy
Returns a new instance of Fuzzy.
7 8 9 |
# File 'lib/page_magic/comparator/fuzzy.rb', line 7 def initialize(comparator) super(comparator, true) end |
Instance Method Details
#<=>(other) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/page_magic/comparator/fuzzy.rb', line 15 def <=>(other) return -1 if other.is_a?(Null) return 1 unless other.fuzzy? 0 end |
#match?(value) ⇒ Boolean
11 12 13 |
# File 'lib/page_magic/comparator/fuzzy.rb', line 11 def match?(value) comparator =~ value ? true : false end |