Sha256: 201355486fe3a1ee7008f1894e7bbef43ea74d873878e7ff7a964f5196637b6e

Contents?: true

Size: 573 Bytes

Versions: 1

Compression:

Stored size: 573 Bytes

Contents

# frozen_string_literal: true

require "api_cache"
require "active_support"
require "icalendar"

module Jekyll
  class IcalTag
    class CalendarParser
      def initialize(url)
        @url = URI.unescape(url)
      end

      def events
        @events ||= begin
          Icalendar::Event.parse(ics_feed)
                          .sort { |e1, e2| e1.dtstart <=> e2.dtstart }
                          .map{|e| Jekyll::IcalTag::Event.new(e) } 
        end
      end

      private

      def ics_feed
        @ics_feed ||= APICache.get(@url)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-ical-tag-1.0.2 lib/jekyll-ical-tag/calendar_parser.rb