Module: UserAgent::Comparable

Included in:
UserAgent, Browsers::All
Defined in:
lib/user_agent/comparable.rb

Overview

A custom Comparable module that will always return false if the <=> returns false

Instance Method Summary collapse

Instance Method Details

#<(other) ⇒ Object



5
6
7
# File 'lib/user_agent/comparable.rb', line 5

def <(other)
  (c = self <=> other) ? c == -1 : false
end

#<=(other) ⇒ Object



9
10
11
# File 'lib/user_agent/comparable.rb', line 9

def <=(other)
  (c = self <=> other) ? c == -1 || c == 0 : false
end

#==(other) ⇒ Object



13
14
15
# File 'lib/user_agent/comparable.rb', line 13

def ==(other)
  (c = self <=> other) ? c == 0 : false
end

#>(other) ⇒ Object



17
18
19
# File 'lib/user_agent/comparable.rb', line 17

def >(other)
  (c = self <=> other) ? c == 1 : false
end

#>=(other) ⇒ Object



21
22
23
# File 'lib/user_agent/comparable.rb', line 21

def >=(other)
  (c = self <=> other) ? c == 1 || c == 0 : false
end