Class: CalendariumRomanum::Remote::Calendar
- Inherits:
-
Object
- Object
- CalendariumRomanum::Remote::Calendar
- 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
-
#calendar_uri ⇒ Object
readonly
Returns the value of attribute calendar_uri.
-
#sanctorale ⇒ Object
readonly
Returns the value of attribute sanctorale.
-
#temporale ⇒ Object
readonly
Returns the value of attribute temporale.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #==(obj) ⇒ Object
- #day(*args) ⇒ Object
- #ferial_lectionary ⇒ Object
-
#initialize(year, calendar_uri, driver: nil) ⇒ Calendar
constructor
A new instance of Calendar.
- #lectionary ⇒ Object
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_uri ⇒ Object (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 |
#sanctorale ⇒ Object (readonly)
Returns the value of attribute sanctorale.
30 31 32 |
# File 'lib/calendarium-romanum/remote/calendar.rb', line 30 def sanctorale @sanctorale end |
#temporale ⇒ Object (readonly)
Returns the value of attribute temporale.
29 30 31 |
# File 'lib/calendarium-romanum/remote/calendar.rb', line 29 def temporale @temporale end |
#year ⇒ Object (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_lectionary ⇒ Object
55 56 57 |
# File 'lib/calendarium-romanum/remote/calendar.rb', line 55 def ferial_lectionary year_spec['ferial_lectionary'].to_i end |
#lectionary ⇒ Object
51 52 53 |
# File 'lib/calendarium-romanum/remote/calendar.rb', line 51 def lectionary year_spec['lectionary'].to_sym end |