Class: Zmanim::Limudim::Anchor::DayOfYearAnchor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(month, day) ⇒ DayOfYearAnchor

Returns a new instance of DayOfYearAnchor.



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

def initialize(month, day)
  @month = month
  @day = day
end

Instance Attribute Details

#dayObject (readonly)

Returns the value of attribute day.



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

def day
  @day
end

#monthObject (readonly)

Returns the value of attribute month.



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

def month
  @month
end

Instance Method Details

#current_or_previous_occurrence(jewish_date) ⇒ Object



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

def current_or_previous_occurrence(jewish_date)
  occurrence = Zmanim::HebrewCalendar::JewishDate.new(jewish_date.jewish_year, month, day)
  occurrence.jewish_year -= 1 if occurrence > jewish_date
  occurrence
end

#next_occurrence(jewish_date) ⇒ Object



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

def next_occurrence(jewish_date)
  occurrence = Zmanim::HebrewCalendar::JewishDate.new(jewish_date.jewish_year, month, day)
  occurrence.jewish_year += 1 if occurrence <= jewish_date
  occurrence
end

#previous_occurrence(jewish_date) ⇒ Object



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

def previous_occurrence(jewish_date)
  occurrence = Zmanim::HebrewCalendar::JewishDate.new(jewish_date.jewish_year, month, day)
  occurrence.jewish_year -= 1 if occurrence >= jewish_date
  occurrence
end