Class: PageMagic::Comparator::Literal

Inherits:
PageMagic::Comparator show all
Defined in:
lib/page_magic/comparator/literal.rb

Overview

class Literal - used for modeling and comparing thing directly. E.g. strings

Instance Attribute Summary

Attributes inherited from PageMagic::Comparator

#comparator, #fuzzy

Instance Method Summary collapse

Methods inherited from PageMagic::Comparator

#==, for, #fuzzy?, #to_s

Constructor Details

#initialize(comparator) ⇒ Literal

Returns a new instance of Literal.



7
8
9
# File 'lib/page_magic/comparator/literal.rb', line 7

def initialize(comparator)
  super(comparator, false)
end

Instance Method Details

#<=>(other) ⇒ Object



15
16
17
18
19
# File 'lib/page_magic/comparator/literal.rb', line 15

def <=>(other)
  return 1 if other.fuzzy? || other.is_a?(Null)

  0
end

#match?(value) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/page_magic/comparator/literal.rb', line 11

def match?(value)
  comparator == value
end