Sha256: e7289b6ceebf5d06911dc48c7a7e5f9cd2a00eb3854a8d553b3e37ebc7cd6a45

Contents?: true

Size: 829 Bytes

Versions: 1

Compression:

Stored size: 829 Bytes

Contents

module CalendariumRomanum
  module Remote
    module V0
      class Deserializer
        def call(day_str)
          parsed = JSON.parse day_str

          season_sym = parsed['season'].to_sym

          CalendariumRomanum::Day.new(
            date: Date.parse(parsed['date']),
            season: CalendariumRomanum::Seasons.all.find {|s| s.symbol == season_sym},
            season_week: parsed['season_week'],
            celebrations: parsed['celebrations'].collect do |c|
              colour_sym = c['colour'].to_sym

              CalendariumRomanum::Celebration.new(
                c['title'],
                CalendariumRomanum::Ranks[c['rank_num']],
                CalendariumRomanum::Colours.all.find {|c| c.symbol == colour_sym }
              )
            end
          )
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
calendarium-romanum-remote-0.1.0 lib/calendarium-romanum/remote/v0/deserializer.rb