Method: Runby::Pace#<=>

Defined in:
lib/runby_pace/pace.rb

#<=>(other) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/runby_pace/pace.rb', line 79

def <=>(other)
  raise "Unable to compare Runby::Pace to #{other.class}(#{other})" unless [Pace, RunbyTime, String].include? other.class
  if other.is_a? Pace
    meters_per_minute.round(2) <=> other.meters_per_minute.round(2)
  elsif other.is_a? RunbyTime
    @time <=> other
  elsif other.is_a? String
    return 0 if to_s == other || to_s(format: :long) == other
    return 0 if @time == other
    self <=> try_parse(other)[:pace]
  end
end