Sha256: cc12e4bec10375a1b275b6ff652ab529d68f8cbd52218413b016a693b8dc9536

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

# encoding: utf-8
# frozen_string_literal: true

module Jekyll
  class IcalTag
    class CalendarLimiter
      def initialize(parser, options = {})
        @parser = parser
        @options = options
      end

      def events
        case
        when options[:only] == :future
          now = Time.now
          parser.events.select do |event|
            event.dtstart.to_time >= now
          end
        when options[:only] == :past
          now = Time.now
          parser.events.select do |event|
            event.dtstart.to_time < now
          end
        when options[:reverse]
          parser.events.reverse
        when options[:after_date]
          parser.events.select do |event|
            event.dtstart.to_time >= options[:after_date]
          end
        when options[:before_date]
          parser.events.select do |event|
            event.dtstart.to_time < options[:before_date]
          end
        else
          parser.events
        end
      end

      private

      attr_reader :parser, :options
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jekyll-ical-tag-1.0.8 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.0.7 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.0.6 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.0.5 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.0.4 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.0.3 lib/jekyll-ical-tag/calendar_limiter.rb