Class: Zmanim::Limudim::Anchor::DayOfWeekAnchor

Inherits:
Object
  • Object
show all
Defined in:
lib/zmanim/limudim/anchor/day_of_week_anchor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(day_of_week) ⇒ DayOfWeekAnchor

Returns a new instance of DayOfWeekAnchor.



4
5
6
# File 'lib/zmanim/limudim/anchor/day_of_week_anchor.rb', line 4

def initialize(day_of_week)
  @day_of_week = day_of_week
end

Instance Attribute Details

#day_of_weekObject (readonly)

Returns the value of attribute day_of_week.



3
4
5
# File 'lib/zmanim/limudim/anchor/day_of_week_anchor.rb', line 3

def day_of_week
  @day_of_week
end

Instance Method Details

#current_or_previous_occurrence(date) ⇒ Object



20
21
22
23
24
# File 'lib/zmanim/limudim/anchor/day_of_week_anchor.rb', line 20

def current_or_previous_occurrence(date)
  offset = day_of_week - date.day_of_week
  offset -= 7 if offset > 0
  date + offset
end

#next_occurrence(date) ⇒ Object



8
9
10
11
12
# File 'lib/zmanim/limudim/anchor/day_of_week_anchor.rb', line 8

def next_occurrence(date)
  offset = day_of_week - date.day_of_week
  offset += 7 if offset <= 0
  date + offset
end

#previous_occurrence(date) ⇒ Object



14
15
16
17
18
# File 'lib/zmanim/limudim/anchor/day_of_week_anchor.rb', line 14

def previous_occurrence(date)
  offset = day_of_week - date.day_of_week
  offset -= 7 if offset >= 0
  date + offset
end