Module: RiCal

Defined in:
lib/ri_cal.rb,
lib/ri_cal/parser.rb,
lib/ri_cal/component.rb,
lib/ri_cal/component/todo.rb,
lib/ri_cal/fast_date_time.rb,
lib/ri_cal/property_value.rb,
lib/ri_cal/component/alarm.rb,
lib/ri_cal/component/event.rb,
lib/ri_cal/properties/todo.rb,
lib/ri_cal/properties/alarm.rb,
lib/ri_cal/properties/event.rb,
lib/ri_cal/component/journal.rb,
lib/ri_cal/floating_timezone.rb,
lib/ri_cal/occurrence_period.rb,
lib/ri_cal/component/calendar.rb,
lib/ri_cal/component/freebusy.rb,
lib/ri_cal/component/timezone.rb,
lib/ri_cal/properties/journal.rb,
lib/ri_cal/property_value/geo.rb,
lib/ri_cal/property_value/uri.rb,
lib/ri_cal/required_timezones.rb,
lib/ri_cal/properties/calendar.rb,
lib/ri_cal/properties/freebusy.rb,
lib/ri_cal/properties/timezone.rb,
lib/ri_cal/property_value/date.rb,
lib/ri_cal/property_value/text.rb,
lib/ri_cal/property_value/array.rb,
lib/ri_cal/occurrence_enumerator.rb,
lib/ri_cal/property_value/period.rb,
lib/ri_cal/invalid_property_value.rb,
lib/ri_cal/property_value/integer.rb,
lib/ri_cal/property_value/duration.rb,
lib/ri_cal/property_value/date_time.rb,
lib/ri_cal/property_value/utc_offset.rb,
lib/ri_cal/invalid_timezone_identifer.rb,
lib/ri_cal/properties/timezone_period.rb,
lib/ri_cal/property_value/cal_address.rb,
lib/ri_cal/property_value/occurrence_list.rb,
lib/ri_cal/property_value/recurrence_rule.rb,
lib/ri_cal/core_extensions/date/conversions.rb,
lib/ri_cal/core_extensions/time/conversions.rb,
lib/ri_cal/core_extensions/time/tzid_access.rb,
lib/ri_cal/core_extensions/array/conversions.rb,
lib/ri_cal/core_extensions/time/calculations.rb,
lib/ri_cal/component/timezone/daylight_period.rb,
lib/ri_cal/component/timezone/standard_period.rb,
lib/ri_cal/component/timezone/timezone_period.rb,
lib/ri_cal/core_extensions/object/conversions.rb,
lib/ri_cal/core_extensions/string/conversions.rb,
lib/ri_cal/core_extensions/date_time/conversions.rb,
lib/ri_cal/property_value/date_time/time_machine.rb,
lib/ri_cal/core_extensions/time/week_day_predicates.rb,
lib/ri_cal/property_value/date_time/additive_methods.rb,
lib/ri_cal/property_value/date_time/timezone_support.rb,
lib/ri_cal/property_value/recurrence_rule/enumerator.rb,
lib/ri_cal/property_value/recurrence_rule/validations.rb,
lib/ri_cal/property_value/recurrence_rule/numbered_span.rb,
lib/ri_cal/property_value/recurrence_rule/recurring_day.rb,
lib/ri_cal/property_value/recurrence_rule/recurring_year_day.rb,
lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb,
lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/initialization_methods.rb,
lib/ri_cal/property_value/recurrence_rule/recurring_numbered_week.rb,
lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb,
lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb

Overview

  • ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license

The RiCal module provides the outermost namespace, along with several convenience methods for parsing and building calendars and calendar components.

Defined Under Namespace

Modules: CoreExtensions, OccurrenceEnumerator, Properties, TimeWithZoneExtension Classes: Component, FastDateTime, FloatingTimezone, InvalidPropertyValue, InvalidTimezoneIdentifier, OccurrencePeriod, Parser, PropertyValue, RequiredTimezones

Constant Summary collapse

VERSION =

:stopdoc:

'0.7.3'
LIBPATH =
::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
PATH =
::File.dirname(LIBPATH) + ::File::SEPARATOR
TimeWithZone =

TimeWithZone will be set to ActiveSupport::TimeWithZone if the activesupport gem is loaded otherwise it will be nil

time_with_zone

Class Method Summary collapse

Class Method Details

.Alarm(&init_block) ⇒ Object

return a new Alarm event or todo component. If a block is provided it will will be executed in the context of a builder object which can be used to initialize the properties of the new Alarm.



80
81
82
# File 'lib/ri_cal.rb', line 80

def self.Alarm(&init_block)
  Component::Alarm.new(&init_block)
end

.Calendar(&init_block) ⇒ Object

return a new Calendar. If a block is provided it will will be executed in the context of a builder object which can be used to initialize the properties and components of the new calendar.



87
88
89
# File 'lib/ri_cal.rb', line 87

def self.Calendar(&init_block)
  Component::Calendar.new(&init_block)
end

.debugObject

:nodoc:



69
70
71
# File 'lib/ri_cal.rb', line 69

def self.debug # :nodoc:
  @debug
end

.debug=(val) ⇒ Object

:nodoc:



73
74
75
# File 'lib/ri_cal.rb', line 73

def self.debug=(val) # :nodoc:
  @debug = val
end

.Event(&init_block) ⇒ Object

return a new Event calendar component. If a block is provided it will will be executed in the context of a builder object which can be used to initialize the properties and alarms of the new Event.



94
95
96
# File 'lib/ri_cal.rb', line 94

def self.Event(&init_block)
  Component::Event.new(&init_block)
end

.Freebusy(&init_block) ⇒ Object

return a new Freebusy calendar component. If a block is provided it will will be executed in the context of a builder object which can be used to initialize the properties and components of the new Freebusy.



101
102
103
# File 'lib/ri_cal.rb', line 101

def self.Freebusy(&init_block)
  Component::Freebusy.new(&init_block)
end

.Journal(&init_block) ⇒ Object

return a new Journal calendar component. If a block is provided it will will be executed in the context of a builder object which can be used to initialize the properties and components of the new Event.



108
109
110
# File 'lib/ri_cal.rb', line 108

def self.Journal(&init_block)
  Component::Journal.new(&init_block)
end

.libpath(*args) ⇒ Object

Returns the library path for the module. If any arguments are given, they will be joined to the end of the libray path using File.join.



31
32
33
# File 'lib/ri_cal.rb', line 31

def self.libpath( *args )
  args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
end

.parse(io) ⇒ Object

Parse an io stream and return an array of iCalendar entities. Normally this will be an array of RiCal::Component::Calendar instances



59
60
61
# File 'lib/ri_cal.rb', line 59

def self.parse(io)
  Parser.new(io).parse
end

.parse_string(string) ⇒ Object

Parse a string and return an array of iCalendar entities. see RiCal.parse



65
66
67
# File 'lib/ri_cal.rb', line 65

def self.parse_string(string)
  parse(StringIO.new(string))
end

.path(*args) ⇒ Object

Returns the lpath for the module. If any arguments are given, they will be joined to the end of the path using File.join.



39
40
41
# File 'lib/ri_cal.rb', line 39

def self.path( *args )
  args.empty? ? PATH : ::File.join(PATH, args.flatten)
end

.RationalOffsetObject



160
161
162
163
164
165
# File 'lib/ri_cal.rb', line 160

def self.RationalOffset
  self.ro_calls += 1
  @rational_offset ||= Hash.new {|h, seconds|
    self.ro_misses += 1
    h[seconds] = Rational(seconds, 86400)}
end

.require_all_libs_relative_to(fname, dir = nil) ⇒ Object

Utility method used to rquire all files ending in .rb that lie in the directory below this file that has the same name as the filename passed in. Optionally, a specific directory name can be passed in such that the filename does not have to be equivalent to the directory.



48
49
50
51
52
53
# File 'lib/ri_cal.rb', line 48

def self.require_all_libs_relative_to( fname, dir = nil )
  dir ||= ::File.basename(fname, '.*')
  search_me = ::File.expand_path(::File.join(::File.dirname(fname), dir, '**', '*.rb'))
  Dir.glob(search_me).sort.each {|rb|
    require rb}
end

.ro_callsObject



148
149
150
# File 'lib/ri_cal.rb', line 148

def self.ro_calls
  @ro_calls ||= 0
end

.ro_calls=(value) ⇒ Object



144
145
146
# File 'lib/ri_cal.rb', line 144

def self.ro_calls=(value)
  @ro_calls = value
end

.ro_missesObject



156
157
158
# File 'lib/ri_cal.rb', line 156

def self.ro_misses
  @ro_misses ||= 0
end

.ro_misses=(value) ⇒ Object



152
153
154
# File 'lib/ri_cal.rb', line 152

def self.ro_misses=(value)
  @ro_misses = value
end

.Timezone(&init_block) ⇒ Object

return a new Timezone calendar component. If a block is provided it will will be executed in the context of a builder object which can be used to initialize the properties and timezone periods of the new Timezone.



115
116
117
# File 'lib/ri_cal.rb', line 115

def self.Timezone(&init_block)
  Component::Timezone.new(&init_block)
end

.TimezonePeriod(&init_block) ⇒ Object

return a new TimezonePeriod timezone component. If a block is provided it will will be executed in the context of a builder object which can be used to initialize the properties of the new TimezonePeriod.



122
123
124
# File 'lib/ri_cal.rb', line 122

def self.TimezonePeriod(&init_block)
  Component::TimezonePeriod.new(&init_block)
end

.Todo(&init_block) ⇒ Object

return a new Todo calendar component. If a block is provided it will will be executed in the context of a builder object which can be used to initialize the properties and alarms of the new Todo.



140
141
142
# File 'lib/ri_cal.rb', line 140

def self.Todo(&init_block)
  Component::Todo.new(&init_block)
end

.versionObject

Returns the version string for the library.



23
24
25
# File 'lib/ri_cal.rb', line 23

def self.version
  VERSION
end