Class: CalendariumRomanum::Remote::Calendar

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/calendarium-romanum/remote/calendar.rb

Overview

Mostly API-compatible with CalendariumRomanum::Calendar (only constructor differs). Instead of computing calendar data, obtains them from a remote calendar API github.com/igneus/church-calendar-api

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(year, calendar_uri, driver: nil) ⇒ Calendar

Returns a new instance of Calendar.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/calendarium-romanum/remote/calendar.rb', line 11

def initialize(year, calendar_uri, driver: nil)
  @year = year
  @calendar_uri = calendar_uri

  @driver =
    driver ||
    Driver.new(
      V0::UriScheme.new(calendar_uri),
      V0::Denormalizer.new
    )

  # only for most fundamental computations made locally
  @temporale = Temporale.new(year)
  # only for API compatibility
  @sanctorale = nil
end

Instance Attribute Details

#calendar_uriObject (readonly)

Returns the value of attribute calendar_uri.



31
32
33
# File 'lib/calendarium-romanum/remote/calendar.rb', line 31

def calendar_uri
  @calendar_uri
end

#sanctoraleObject (readonly)

Returns the value of attribute sanctorale.



30
31
32
# File 'lib/calendarium-romanum/remote/calendar.rb', line 30

def sanctorale
  @sanctorale
end

#temporaleObject (readonly)

Returns the value of attribute temporale.



29
30
31
# File 'lib/calendarium-romanum/remote/calendar.rb', line 29

def temporale
  @temporale
end

#yearObject (readonly)

Returns the value of attribute year.



28
29
30
# File 'lib/calendarium-romanum/remote/calendar.rb', line 28

def year
  @year
end

Instance Method Details

#==(obj) ⇒ Object



59
60
61
62
63
# File 'lib/calendarium-romanum/remote/calendar.rb', line 59

def ==(obj)
  self.class == obj.class &&
    self.year == obj.year &&
    self.calendar_uri == obj.calendar_uri
end

#day(*args) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/calendarium-romanum/remote/calendar.rb', line 35

def day(*args)
  # TODO code copied from CalendariumRomanum::Calendar -
  # extract to a separate method
  if args.size == 2
    date = Date.new(@year, *args)
    unless @temporale.date_range.include? date
      date = Date.new(@year + 1, *args)
    end
  else
    date = CalendariumRomanum::Calendar.mk_date *args
    #range_check date
  end

  @driver.day date
end

#ferial_lectionaryObject



55
56
57
# File 'lib/calendarium-romanum/remote/calendar.rb', line 55

def ferial_lectionary
  year_spec['ferial_lectionary'].to_i
end

#lectionaryObject



51
52
53
# File 'lib/calendarium-romanum/remote/calendar.rb', line 51

def lectionary
  year_spec['lectionary'].to_sym
end