Class: Datey::Interrogator
- Inherits:
-
Object
- Object
- Datey::Interrogator
- Defined in:
- lib/datey/interrogator.rb
Instance Method Summary collapse
-
#future? ⇒ Boolean
Is the time in the future.
-
#initialize(date) ⇒ Interrogator
constructor
A new instance of Interrogator.
-
#last_week? ⇒ Boolean
Does the date exist in the full week prior to the current week.
-
#last_x_days?(days) ⇒ Boolean
Does the date occur in the last X days not including today?.
-
#next_week? ⇒ Boolean
Does the date occur next week? Assuming the next Sunday is the start of the next week.
-
#next_x_days?(days) ⇒ Boolean
Does the date occur in the next X days not including today?.
-
#past? ⇒ Boolean
Is the time in the past.
-
#this_week? ⇒ Boolean
Does the date existing in this week.
-
#today? ⇒ Boolean
Does the time occur today?.
-
#tomorrow? ⇒ Boolean
Does the time occur tomorrow?.
-
#yesterday? ⇒ Boolean
Does the time occur yesterday?.
Constructor Details
#initialize(date) ⇒ Interrogator
Returns a new instance of Interrogator.
6 7 8 9 |
# File 'lib/datey/interrogator.rb', line 6 def initialize(date) @date = date.to_date @today = Date.today end |
Instance Method Details
#future? ⇒ Boolean
Is the time in the future
80 81 82 |
# File 'lib/datey/interrogator.rb', line 80 def future? @date > @today end |
#last_week? ⇒ Boolean
Does the date exist in the full week prior to the current week
35 36 37 38 |
# 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) ⇒ Boolean
Does the date occur in the last X days not including today?
43 44 45 |
# File 'lib/datey/interrogator.rb', line 43 def last_x_days?(days) @date >= (@today - days) && @date < @today end |
#next_week? ⇒ Boolean
Does the date occur next week? Assuming the next Sunday is the start of the next week.
65 66 67 68 |
# 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) ⇒ Boolean
Does the date occur in the next X days not including today?
50 51 52 |
# File 'lib/datey/interrogator.rb', line 50 def next_x_days?(days) @date > @today && @date <= (@today + days) end |
#past? ⇒ Boolean
Is the time in the past
73 74 75 |
# File 'lib/datey/interrogator.rb', line 73 def past? @date < @today end |
#this_week? ⇒ Boolean
Does the date existing in this week.
57 58 59 |
# File 'lib/datey/interrogator.rb', line 57 def this_week? @date >= beginning_of_current_week && @date < beginning_of_current_week + 7 end |
#today? ⇒ Boolean
Does the time occur today?
14 15 16 |
# File 'lib/datey/interrogator.rb', line 14 def today? @date == @today end |
#tomorrow? ⇒ Boolean
Does the time occur tomorrow?
21 22 23 |
# File 'lib/datey/interrogator.rb', line 21 def tomorrow? @date == (@today + 1) end |
#yesterday? ⇒ Boolean
Does the time occur yesterday?
28 29 30 |
# File 'lib/datey/interrogator.rb', line 28 def yesterday? @date == (@today - 1) end |