Sha256: 3f68afd919642d4b18e44c2c2eac0275afc08d7f7a995b129b8c05b0602465c9

Contents?: true

Size: 779 Bytes

Versions: 9

Compression:

Stored size: 779 Bytes

Contents

require 'icalendar'
require 'date'
module Timetrap
  module Formatters
    class Ical
      include Icalendar
      def calendar
        @calendar ||= Calendar.new
      end

      def output
        calendar.to_ical
      end

      def initialize entries
        entries.each do |e|
          next unless e.end
          calendar.event do

            # hack around an issue in ical gem in ruby 1.9
            unless respond_to? :<=>
              def <=> other
                dtstart > other.dtstart ? 1 : 0
              end
            end

            dtstart DateTime.parse(e.start.to_s)
            dtend DateTime.parse(e.end.to_s)
            summary e.note
            description e.note
          end
        end
        calendar.publish
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
timetrap-1.6.1 lib/timetrap/formatters/ical.rb
timetrap-1.6.0 lib/timetrap/formatters/ical.rb
timetrap-1.5.3 lib/timetrap/formatters/ical.rb
timetrap-1.5.2 lib/timetrap/formatters/ical.rb
timetrap-1.5.1 lib/timetrap/formatters/ical.rb
timetrap-1.5.0 lib/timetrap/formatters/ical.rb
timetrap-1.4.1 lib/timetrap/formatters/ical.rb
timetrap-1.4.0 lib/timetrap/formatters/ical.rb
timetrap-1.3.0 lib/timetrap/formatters/ical.rb