Class: Zmanim::Limudim::Anchor::DayOfMonthAnchor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(day) ⇒ DayOfMonthAnchor

Returns a new instance of DayOfMonthAnchor.



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

def initialize(day)
  @day = day
end

Instance Attribute Details

#dayObject (readonly)

Returns the value of attribute day.



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

def day
  @day
end

Instance Method Details

#current_or_previous_occurrence(jewish_date) ⇒ Object



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

def current_or_previous_occurrence(jewish_date)
  occurrence = Zmanim::HebrewCalendar::JewishDate.new(jewish_date.jewish_year, jewish_date.jewish_month, day)
  decrement_month(occurrence) if occurrence > jewish_date
  occurrence
end

#next_occurrence(jewish_date) ⇒ Object



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

def next_occurrence(jewish_date)
  occurrence = Zmanim::HebrewCalendar::JewishDate.new(jewish_date.jewish_year, jewish_date.jewish_month, day)
  increment_month(occurrence) if occurrence <= jewish_date
  occurrence
end

#previous_occurrence(jewish_date) ⇒ Object



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

def previous_occurrence(jewish_date)
  occurrence = Zmanim::HebrewCalendar::JewishDate.new(jewish_date.jewish_year, jewish_date.jewish_month, day)
  decrement_month(occurrence) if occurrence >= jewish_date
  occurrence
end