Class: Ical2gcal::Ics::Events

Inherits:
Object
  • Object
show all
Defined in:
lib/ics/events.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Events

Returns a new instance of Events.



12
13
14
15
# File 'lib/ics/events.rb', line 12

def initialize( uri )
  @uri       = uri
  @calendars = nil
end

Instance Method Details

#calendarsObject



17
18
19
20
21
22
23
# File 'lib/ics/events.rb', line 17

def calendars
  if ( @uri and !@calendars )
    @calendars = RiCal.parse( open( @uri ) )
  end

  @calendars
end

#each(&block) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/ics/events.rb', line 29

def each( &block )
  calendars.each { |c|
    c.events.each { |e|
      block.call( e )
    }
  }
end

#getObject



25
26
27
# File 'lib/ics/events.rb', line 25

def get
  calendars.map { |c| c.events }.flatten
end