Sha256: b32cd7220951c6a35a9a34cb08d29ec301998e38314d480db1de4408b5f7ce0c

Contents?: true

Size: 1.1 KB

Versions: 16

Compression:

Stored size: 1.1 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
        when options[:limit]
          parser.events.first(options[:limit])
        else
          parser.events
        end
      end

      private

      attr_reader :parser, :options
    end
  end
end

Version data entries

16 entries across 15 versions & 1 rubygems

Version Path
jekyll-ical-tag-1.5.1 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.5 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.4.0 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.4.0 _site/lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.3.3 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.3.2 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.3.1 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.3 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.2.5 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.2.4 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.2.3 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.2.2 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.2.1 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.2.0 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.1.0 lib/jekyll-ical-tag/calendar_limiter.rb
jekyll-ical-tag-1.0.9 lib/jekyll-ical-tag/calendar_limiter.rb