class Datey::Interrogator
Public Class Methods
new(date)
click to toggle source
# File lib/datey/interrogator.rb, line 6 def initialize(date) @date = date.to_date @today = Date.today end
Public Instance Methods
future?()
click to toggle source
Is the time in the future
# File lib/datey/interrogator.rb, line 80 def future? @date > @today end
last_week?()
click to toggle source
Does the date exist in the full week prior to the current week
# File lib/datey/interrogator.rb, line 35 def last_week? beginning_of_previous_week = beginning_of_current_week - 7 @date >= beginning_of_previous_week && @date < beginning_of_previous_week + 7 end
last_x_days?(days)
click to toggle source
Does the date occur in the last X days not including today?
# File lib/datey/interrogator.rb, line 43 def last_x_days?(days) @date >= (@today - days) && @date < @today end
next_week?()
click to toggle source
Does the date occur next week? Assuming the next Sunday is the start of the next week.
# File lib/datey/interrogator.rb, line 65 def next_week? beginning_of_next_week = beginning_of_current_week + 7 @date >= beginning_of_next_week && @date < beginning_of_next_week + 7 end
next_x_days?(days)
click to toggle source
Does the date occur in the next X days not including today?
# File lib/datey/interrogator.rb, line 50 def next_x_days?(days) @date > @today && @date <= (@today + days) end
past?()
click to toggle source
Is the time in the past
# File lib/datey/interrogator.rb, line 73 def past? @date < @today end
this_week?()
click to toggle source
Does the date existing in this week.
# File lib/datey/interrogator.rb, line 57 def this_week? @date >= beginning_of_current_week && @date < beginning_of_current_week + 7 end
today?()
click to toggle source
Does the time occur today?
# File lib/datey/interrogator.rb, line 14 def today? @date == @today end
tomorrow?()
click to toggle source
Does the time occur tomorrow?
# File lib/datey/interrogator.rb, line 21 def tomorrow? @date == (@today + 1) end
yesterday?()
click to toggle source
Does the time occur yesterday?
# File lib/datey/interrogator.rb, line 28 def yesterday? @date == (@today - 1) end
Private Instance Methods
beginning_of_current_week()
click to toggle source
# File lib/datey/interrogator.rb, line 86 def beginning_of_current_week @beginning_of_current_week ||= @today - @today.wday end