Module: PartiallyComparable

Included in:
LanguageTag
Defined in:
src/lib/language_tag.rb

Overview

Comparable enforces a total ordering, contrary to its documentation, WTF.

Instance Method Summary collapse

Instance Method Details

#<(other) ⇒ Object


18
19
20
21
22
# File 'src/lib/language_tag.rb', line 18

def <(other)
  cmp = self.<=>(other)
  return nil if cmp.nil?
  cmp < 0
end

#<=(other) ⇒ Object


30
31
32
33
34
# File 'src/lib/language_tag.rb', line 30

def <=(other)
  cmp = self.<=>(other)
  return nil if cmp.nil?
  cmp <= 0
end

#==(other) ⇒ Object


42
43
44
45
46
47
# File 'src/lib/language_tag.rb', line 42

def ==(other)
  return true if equal?(other) # object identity
  cmp = self.<=>(other)
  return nil if cmp.nil?
  cmp == 0
end

#>(other) ⇒ Object


24
25
26
27
28
# File 'src/lib/language_tag.rb', line 24

def >(other)
  cmp = self.<=>(other)
  return nil if cmp.nil?
  cmp > 0
end

#>=(other) ⇒ Object


36
37
38
39
40
# File 'src/lib/language_tag.rb', line 36

def >=(other)
  cmp = self.<=>(other)
  return nil if cmp.nil?
  cmp >= 0
end