Class: RiCal::Component::Calendar
- Inherits:
-
RiCal::Component
- Object
- RiCal::Component
- RiCal::Component::Calendar
- Includes:
- Properties::Calendar
- Defined in:
- lib/ri_cal/component/calendar.rb
Overview
-
©2009 Rick DeNatale
-
All rights reserved. Refer to the file README.txt for the license
to see the property accessing methods for this class see the RiCal::Properties::Calendar module
Defined Under Namespace
Classes: FoldingStream, TZInfoWrapper, TimezoneID
Instance Attribute Summary collapse
-
#tz_source ⇒ Object
readonly
:nodoc:.
Attributes inherited from RiCal::Component
Class Method Summary collapse
-
.entity_name ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#add_subcomponent(component) ⇒ Object
add an event to the calendar.
-
#events ⇒ Object
return an array of event components contained within this Calendar.
-
#export(to = nil) ⇒ Object
Export this calendar as an iCalendar file.
-
#export_properties_to(export_stream) ⇒ Object
:nodoc:.
-
#export_required_timezones(export_stream) ⇒ Object
:nodoc:.
-
#find_timezone(identifier) ⇒ Object
:nodoc:.
-
#freebusys ⇒ Object
return an array of freebusy components contained within this Calendar.
-
#initialize(parent = nil, &init_block) ⇒ Calendar
constructor
:nodoc:.
-
#journals ⇒ Object
return an array of journal components contained within this Calendar.
-
#prodid_property_from_string(line) ⇒ Object
:nodoc:.
-
#required_timezones ⇒ Object
:nodoc:.
-
#subcomponent_class ⇒ Object
:nodoc:.
-
#timezones ⇒ Object
return an array of timezone components contained within this calendar.
-
#todos ⇒ Object
return an array of todo components contained within this Calendar.
-
#tz_info_source? ⇒ Boolean
:nodoc:.
Methods included from Properties::Calendar
#==, #add_date_times_to, #calscale, #calscale_property, #calscale_property_from_string, #icalendar_method, #icalendar_method=, included, #initialize_copy, #method_property, #method_property=, #method_property_from_string, #mutual_exclusion_violation, #prodid, #prodid=, #prodid_property, #prodid_property=, #version, #version_property, #version_property_from_string
Methods inherited from RiCal::Component
#add_property_date_times_to, #add_x_property, #alarms, #daylight, #entity_name, #export_prop_to, #export_subcomponent_to, #export_to, #export_x_properties_to, from_parser, #imported?, #initialize_copy, #last_before_local, #last_before_utc, #last_period, #method_missing, parse, parse_string, #parse_subcomponent, #process_line, #prop_string, #standard, #subcomponents, #time_zone_for, #to_s, #valid?, #x_properties
Constructor Details
#initialize(parent = nil, &init_block) ⇒ Calendar
:nodoc:
13 14 15 16 |
# File 'lib/ri_cal/component/calendar.rb', line 13 def initialize(parent=nil, &init_block) #:nodoc: super @tz_source = 'TZINFO' # Until otherwise told end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RiCal::Component
Instance Attribute Details
#tz_source ⇒ Object (readonly)
:nodoc:
11 12 13 |
# File 'lib/ri_cal/component/calendar.rb', line 11 def tz_source @tz_source end |
Class Method Details
.entity_name ⇒ Object
:nodoc:
18 19 20 |
# File 'lib/ri_cal/component/calendar.rb', line 18 def self.entity_name #:nodoc: "VCALENDAR" end |
Instance Method Details
#add_subcomponent(component) ⇒ Object
add an event to the calendar
60 61 62 63 |
# File 'lib/ri_cal/component/calendar.rb', line 60 def add_subcomponent(component) super(component) component.add_date_times_to(required_timezones) if tz_info_source? end |
#events ⇒ Object
return an array of event components contained within this Calendar
55 56 57 |
# File 'lib/ri_cal/component/calendar.rb', line 55 def events subcomponents["VEVENT"] end |
#export(to = nil) ⇒ Object
Export this calendar as an iCalendar file. if to is nil (the default) then this method will return a string, otherwise to should be an IO to which the iCalendar file contents will be written
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/ri_cal/component/calendar.rb', line 177 def export(to=nil) export_stream = FoldingStream.new(to) export_stream.puts("BEGIN:VCALENDAR") #TODO: right now I'm assuming that all timezones are internal what happens when we export # an imported calendar. export_properties_to(export_stream) export_x_properties_to(export_stream) export_required_timezones(export_stream) export_subcomponent_to(export_stream, events) export_subcomponent_to(export_stream, todos) export_subcomponent_to(export_stream, journals) export_subcomponent_to(export_stream, freebusys) export_stream.puts("END:VCALENDAR") if to nil else export_stream.string end end |
#export_properties_to(export_stream) ⇒ Object
:nodoc:
40 41 42 43 44 45 46 |
# File 'lib/ri_cal/component/calendar.rb', line 40 def export_properties_to(export_stream) # :nodoc: prodid_property.params["X-RICAL-TZSOURCE"] = @tz_source export_prop_to(export_stream, "PRODID", prodid_property) export_prop_to(export_stream, "CALSCALE", calscale_property) export_prop_to(export_stream, "VERSION", version_property) export_prop_to(export_stream, "METHOD", method_property) end |
#export_required_timezones(export_stream) ⇒ Object
:nodoc:
142 143 144 |
# File 'lib/ri_cal/component/calendar.rb', line 142 def export_required_timezones(export_stream) # :nodoc: required_timezones.export_to(export_stream) end |
#find_timezone(identifier) ⇒ Object
:nodoc:
128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/ri_cal/component/calendar.rb', line 128 def find_timezone(identifier) #:nodoc: if tz_info_source? begin TZInfoWrapper.new(TZInfo::Timezone.get(identifier), self) rescue ::TZInfo::InvalidTimezoneIdentifier => ex raise RiCal::InvalidTimezoneIdentifier.invalid_tzinfo_identifier(identifier) end else result = timezones.find {|tz| tz.tzid == identifier} raise RiCal::InvalidTimezoneIdentifier.not_found_in_calendar(identifier) unless result result end end |
#freebusys ⇒ Object
return an array of freebusy components contained within this Calendar
76 77 78 |
# File 'lib/ri_cal/component/calendar.rb', line 76 def freebusys subcomponents["VFREEBUSY"] end |
#journals ⇒ Object
return an array of journal components contained within this Calendar
71 72 73 |
# File 'lib/ri_cal/component/calendar.rb', line 71 def journals subcomponents["VJOURNAL"] end |
#prodid_property_from_string(line) ⇒ Object
:nodoc:
48 49 50 51 52 |
# File 'lib/ri_cal/component/calendar.rb', line 48 def prodid_property_from_string(line) # :nodoc: result = super @tz_source = prodid_property.params["X-RICAL-TZSOURCE"] result end |
#required_timezones ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/ri_cal/component/calendar.rb', line 26 def required_timezones # :nodoc: @required_timezones ||= RequiredTimezones.new end |
#subcomponent_class ⇒ Object
:nodoc:
30 31 32 33 34 35 36 37 38 |
# File 'lib/ri_cal/component/calendar.rb', line 30 def subcomponent_class # :nodoc: { :event => Event, :todo => Todo, :journal => Journal, :freebusy => Freebusy, :timezone => Timezone, } end |
#timezones ⇒ Object
return an array of timezone components contained within this calendar
100 101 102 |
# File 'lib/ri_cal/component/calendar.rb', line 100 def timezones subcomponents["VTIMEZONE"] end |
#todos ⇒ Object
return an array of todo components contained within this Calendar
66 67 68 |
# File 'lib/ri_cal/component/calendar.rb', line 66 def todos subcomponents["VTODO"] end |
#tz_info_source? ⇒ Boolean
:nodoc:
22 23 24 |
# File 'lib/ri_cal/component/calendar.rb', line 22 def tz_info_source? #:nodoc: @tz_source == 'TZINFO' end |