diff --git a/lib/time_difference.rb b/lib/time_difference.rb index 589e202..f039177 100644 --- a/lib/time_difference.rb +++ b/lib/time_difference.rb @@ -3,6 +3,7 @@ class TimeDifference + attr_reader :time_diff private_class_method :new TIME_COMPONENTS = [:years, :months, :weeks, :days, :hours, :minutes, :seconds] @@ -78,6 +79,10 @@ def humanize return [diff_parts.join(', '), last_part].join(' and ') end end + + def <=>(other) + @time_diff <=> other.time_diff + end private