Class: CalendariumRomanum::Temporale::EasterTable

Inherits:
Object
  • Object
show all
Defined in:
lib/calendarium-romanum/temporale/easter_table.rb

Overview

Since:

  • 0.8.0

Class Method Summary collapse

Class Method Details

.load_from(src) ⇒ Hash<Integer=>Date>

Loads an Easter table from a String- or IO-like object src. src must contain Easter dates, parseable by Date.parse, one date per line. Blank lines and bash-like comments are ignored. Returns a Hash mapping (liturgical) year to Easter date.

Parameters:

  • src (#each_line)

Returns:

  • (Hash<Integer=>Date>)

Since:

  • 0.8.0



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/calendarium-romanum/temporale/easter_table.rb', line 12

def self.load_from(src)
  r = {}
  src.each_line do |l|
    cleaned = l.sub(/#.*$/, '').strip
    next if cleaned == ''

    date = Date.parse cleaned
    liturgical_year = date.year - 1
    r[liturgical_year] = date
  end

  r
end