Class: Zmanim::Limudim::Calculators::PirkeiAvos

Inherits:
Object
  • Object
show all
Includes:
LimudCalculator
Defined in:
lib/zmanim/limudim/calculators/pirkei_avos.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LimudCalculator

#default_starting_page, #find_cycle, #find_offset_units, #fractional_units, #initial_cycle_date, #limud, #skip_unit, #starting_page, #tiered_units_for_interval, #unit_for_interval, #unit_step

Constructor Details

#initialize(in_israel: false) ⇒ PirkeiAvos

Returns a new instance of PirkeiAvos.



9
10
11
# File 'lib/zmanim/limudim/calculators/pirkei_avos.rb', line 9

def initialize(in_israel:false)
  @in_israel = in_israel
end

Instance Attribute Details

#in_israelObject (readonly)

Returns the value of attribute in_israel.



7
8
9
# File 'lib/zmanim/limudim/calculators/pirkei_avos.rb', line 7

def in_israel
  @in_israel
end

Instance Method Details

#cycle_end_calculationObject



25
26
27
28
29
30
# File 'lib/zmanim/limudim/calculators/pirkei_avos.rb', line 25

def cycle_end_calculation
  ->(start_date, _iteration) do
    rosh_hashana = Zmanim::HebrewCalendar::JewishDate.new(start_date.jewish_year + 1, 7, 1)
    rosh_hashana - rosh_hashana.day_of_week  # last Shabbos before Rosh Hashanah
  end
end

#cycle_units_calculationObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/zmanim/limudim/calculators/pirkei_avos.rb', line 42

def cycle_units_calculation
  ->(cycle) do
    cycle_weeks = ((cycle.end_date - cycle.start_date + 1) / 7.0).ceil
    # If the cycle starts on a Friday, outside of israel the 2nd day of Shavuos will fall on Shabbos
    # and we lose one week in the pirkei avos cycle
    cycle_weeks -=1 if !in_israel && cycle.start_date.day_of_week == 6
    unit_count = default_units.length
    compress_weeks = (unit_count - cycle_weeks) * 2
    default_units.first(unit_count - compress_weeks) + default_units.last(compress_weeks).each_slice(2).to_a
  end
end

#default_unitsObject



21
22
23
# File 'lib/zmanim/limudim/calculators/pirkei_avos.rb', line 21

def default_units
  @default_units ||= (1..6).to_a * 4    # 4 sub-cycles of 6 perakim, with the last sub-cycle being compressed as needed
end

#interval_end_calculationObject



32
33
34
35
36
# File 'lib/zmanim/limudim/calculators/pirkei_avos.rb', line 32

def interval_end_calculation
  ->(cycle, start_date) do
    start_date + (7 - start_date.day_of_week)
  end
end

#perpetual_cycle_anchorObject



17
18
19
# File 'lib/zmanim/limudim/calculators/pirkei_avos.rb', line 17

def perpetual_cycle_anchor
  Zmanim::Limudim::Anchor::DayOfYearAnchor.new(1, in_israel ? 22 : 23) # Day after Pesach
end

#skip_interval?(interval) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/zmanim/limudim/calculators/pirkei_avos.rb', line 38

def skip_interval?(interval)
  !in_israel && [interval.end_date.jewish_month, interval.end_date.jewish_day] == [3,7]
end

#tiered_units?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/zmanim/limudim/calculators/pirkei_avos.rb', line 13

def tiered_units?
  false
end