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.
-
#default_tzid ⇒ Object
Return the default time zone identifier for this calendar.
-
#default_tzid=(value) ⇒ Object
Set the default time zone identifier for this calendar To set the default to floating times use a value of :floating.
-
#events ⇒ Object
return an array of event components contained within this Calendar.
-
#export(to = nil) ⇒ Object
(also: #export_to)
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, entity_name = 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_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, entity_name = nil, &init_block) ⇒ Calendar
:nodoc:
10 11 12 13 |
# File 'lib/ri_cal/component/calendar.rb', line 10 def initialize(parent=nil,entity_name = nil, &init_block) #:nodoc: @tz_source = 'TZINFO' # Until otherwise told super 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:
8 9 10 |
# File 'lib/ri_cal/component/calendar.rb', line 8 def tz_source @tz_source end |
Class Method Details
.entity_name ⇒ Object
:nodoc:
15 16 17 |
# File 'lib/ri_cal/component/calendar.rb', line 15 def self.entity_name #:nodoc: "VCALENDAR" end |
Instance Method Details
#add_subcomponent(component) ⇒ Object
add an event to the calendar
68 69 70 71 |
# File 'lib/ri_cal/component/calendar.rb', line 68 def add_subcomponent(component) super(component) component.add_date_times_to(required_timezones) if tz_info_source? end |
#default_tzid ⇒ Object
Return the default time zone identifier for this calendar
52 53 54 |
# File 'lib/ri_cal/component/calendar.rb', line 52 def default_tzid @default_tzid || PropertyValue::DateTime.default_tzid end |
#default_tzid=(value) ⇒ Object
Set the default time zone identifier for this calendar To set the default to floating times use a value of :floating
58 59 60 |
# File 'lib/ri_cal/component/calendar.rb', line 58 def default_tzid=(value) @default_tzid=value end |
#events ⇒ Object
return an array of event components contained within this Calendar
63 64 65 |
# File 'lib/ri_cal/component/calendar.rb', line 63 def events subcomponents["VEVENT"] end |
#export(to = nil) ⇒ Object Also known as: export_to
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
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/ri_cal/component/calendar.rb', line 230 def export(to=nil) export_stream = FoldingStream.new(to) export_stream.puts("BEGIN:VCALENDAR") 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) subcomponents.each do |key, value| unless %{VEVENT VTODO VJOURNAL VFREEBUSYS}.include?(key) export_subcomponent_to(export_stream, value) end end export_stream.puts("END:VCALENDAR") if to nil else export_stream.string end end |
#export_properties_to(export_stream) ⇒ Object
:nodoc:
37 38 39 40 41 42 43 |
# File 'lib/ri_cal/component/calendar.rb', line 37 def export_properties_to(export_stream) # :nodoc: prodid_property.params["X-RICAL-TZSOURCE"] = @tz_source if @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:
160 161 162 |
# File 'lib/ri_cal/component/calendar.rb', line 160 def export_required_timezones(export_stream) # :nodoc: required_timezones.export_to(export_stream) end |
#find_timezone(identifier) ⇒ Object
:nodoc:
146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/ri_cal/component/calendar.rb', line 146 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
84 85 86 |
# File 'lib/ri_cal/component/calendar.rb', line 84 def freebusys subcomponents["VFREEBUSY"] end |
#journals ⇒ Object
return an array of journal components contained within this Calendar
79 80 81 |
# File 'lib/ri_cal/component/calendar.rb', line 79 def journals subcomponents["VJOURNAL"] end |
#prodid_property_from_string(line) ⇒ Object
:nodoc:
45 46 47 48 49 |
# File 'lib/ri_cal/component/calendar.rb', line 45 def prodid_property_from_string(line) # :nodoc: result = super @tz_source = prodid_property.params["X-RICAL-TZSOURCE"] result end |
#required_timezones ⇒ Object
:nodoc:
23 24 25 |
# File 'lib/ri_cal/component/calendar.rb', line 23 def required_timezones # :nodoc: @required_timezones ||= RequiredTimezones.new end |
#subcomponent_class ⇒ Object
:nodoc:
27 28 29 30 31 32 33 34 35 |
# File 'lib/ri_cal/component/calendar.rb', line 27 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
108 109 110 |
# File 'lib/ri_cal/component/calendar.rb', line 108 def timezones subcomponents["VTIMEZONE"] end |
#todos ⇒ Object
return an array of todo components contained within this Calendar
74 75 76 |
# File 'lib/ri_cal/component/calendar.rb', line 74 def todos subcomponents["VTODO"] end |
#tz_info_source? ⇒ Boolean
:nodoc:
19 20 21 |
# File 'lib/ri_cal/component/calendar.rb', line 19 def tz_info_source? #:nodoc: @tz_source == 'TZINFO' end |