lib/calrom/formatter/json.rb in calrom-0.3.0 vs lib/calrom/formatter/json.rb in calrom-0.4.0
- old
+ new
@@ -1,17 +1,17 @@
require 'json'
module Calrom
module Formatter
# JSON format mimicking Church Calendar API v0 (https://github.com/igneus/church-calendar-api)
- class Json
+ class Json < Formatter
def call(calendar, date_range)
# We build the outer JSON Array manually in order to be able to print
# vast amounts of calendar data without risking RAM exhaustion.
print "["
- date_range.each_with_index do |date, i|
- day = calendar[date]
+ calendar.each_day_in_range(date_range).each_with_index do |day,i|
+ date = day.date
hash = {
date: date,
season: day.season.symbol,
season_week: day.season_week,
celebrations: day.celebrations.collect do |c|