module BeforeAndAfter

Constants

LEFT_SIDE_LATER
RIGHT_SIDE_LATER

Public Instance Methods

after?(input_time) click to toggle source
  • input_time - time to compare

    Time.now.after?(2.hours.ago)
    
# File lib/before_and_after.rb, line 18
def after?(input_time)
  (self.utc <=> input_time.utc) == 1
end
before?(input_time) click to toggle source
  • input_time - time to compare

    Time.now.before?(2.hours.from_now)
    
# File lib/before_and_after.rb, line 10
def before?(input_time)
  (self.utc <=> input_time.utc) == -1
end
within_coming?(time_span) click to toggle source
  • time_span - time span in seconds

    2.minutes.from_now.within_coming?(2.hours)
    
# File lib/before_and_after.rb, line 35
def within_coming?(time_span)
  now = Time.now.utc
  self.utc.between?(now, now +  time_span)
end
within_last?(time_span) click to toggle source
  • time_span - time span in seconds

    2.minutes.ago.within_last?(2.hours)
    
# File lib/before_and_after.rb, line 26
def within_last?(time_span)
  now = Time.now.utc
  self.utc.between?(now - time_span, now)
end