class CalendariumRomanum::Remote::Calendar
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
Attributes
calendar_uri[R]
sanctorale[R]
temporale[R]
year[R]
Public Class Methods
new(year, calendar_uri, driver: nil)
click to toggle source
# 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
Public Instance Methods
==(b)
click to toggle source
# File lib/calendarium-romanum/remote/calendar.rb, line 84 def ==(b) self.class == b.class && self.year == b.year && self.calendar_uri == b.calendar_uri end
[](args)
click to toggle source
TODO literally copied from CalendariumRomanum::Calendar
# File lib/calendarium-romanum/remote/calendar.rb, line 60 def [](args) if args.is_a?(Range) args.map {|date| day(date) } else day(args) end end
day(*args, vespers: false)
click to toggle source
# File lib/calendarium-romanum/remote/calendar.rb, line 39 def day(*args, vespers: false) if vespers != false throw ArgumentError.new('Vespers data supported, but this implementation currently doesn\'t support computing vespers.') end # 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
each() { |day(date)| ... }
click to toggle source
TODO literally copied from CalendariumRomanum::Calendar
# File lib/calendarium-romanum/remote/calendar.rb, line 69 def each return to_enum(__method__) unless block_given? temporale.date_range .each {|date| yield(day(date)) } end
ferial_lectionary()
click to toggle source
# File lib/calendarium-romanum/remote/calendar.rb, line 80 def ferial_lectionary year_spec['ferial_lectionary'].to_i end
lectionary()
click to toggle source
# File lib/calendarium-romanum/remote/calendar.rb, line 76 def lectionary year_spec['lectionary'].to_sym end
populates_vespers?()
click to toggle source
# File lib/calendarium-romanum/remote/calendar.rb, line 35 def populates_vespers? false end
Private Instance Methods
year_spec()
click to toggle source
# File lib/calendarium-romanum/remote/calendar.rb, line 92 def year_spec @year_spec ||= @driver.year(@year) end