Hello everyone,
Well, after finally getting moved into my new digs I''ve gotten back
to
hacking on the icalendar library. I think I''ve fixed all of the bugs
that have been reported so far, and I added true support for timezones,
including its sub-components STANDARD and DAYLIGHT. Additionally I did
a bit of refactoring to clean up the internals a bit, and I think the
property parameter functionality on the back-end is ready. The main
problem now is that I''m not sure how to give people access to the
property parameters. If anyone has an idea on a clean way to do this it
would be great! Here, code is worth at least a couple hundred words...
# Standard stuff...
cal = Icalendar::Calendar.new
cal.event do
user_id = "joe-bob at somewhere.net"
timestamp = DateTime.now
start = Date.new(2005, 04, 29)
end = Date.new(2005, 04, 28)
# First, the simple case for properties with a single instance...
---
# It could work something like this with a hash
summary = "Meeting with the man.", {''LANGUAGE''
=> ''us-EN''}
# Or like this with just a string (maybe more flexible for
# weird/custom stuff). This requires more knowledge about the
# specification, but anyone using parameters is probably referencing
# it anyway...
summary = "Meeting with the man.", "LANGUAGE=us-EN"
~~~
# And then to retrieve these I guess it would have to be explicit
mySummary = event.summary
myParams = event.summary_params
# Otherwise it would have to return a hash or an array, which would
# make things more difficult for the general case without parameters.
mySummary = event.summary[:value]
myParams = event.summary[:params]
---
# Now the hard thing is figuring out what to do for properties
# which can occur multiple times, like attendee...
# It could still use hashes to set
add_attendee ''mailto:joe at company.com'',
{''ROLE'' => ''REQ-PARTICIPANT'',
''PARTSTAT'' => ''TENTATIVE''}
# Or maybe strings
add_attendee ''mailto:bob at company.com'',
''ROLE=REQ-PARTICIPANT'',
''PARTSTAT=ACCEPTED''
~~~
# But how should retrieval work since this is an array of attendees?
# Maybe by default it could return just an array of values, but if
# you as for it with parameters it would give you an array of hashes.
myAttendees = event.attendees # => [''mailto:joe at
company.com'',
''mailto:bob at company.com'']
myAttendeesParams = event.attendees_with_params
#=> [{:value => ''mailto:joe at company.com'',
''ROLE'' => ''REQ-PARTICIPANT'',
''PARTSTAT'' => ''ACCEPTED''}, {:value =>
''mailto:bob at company.com''... etc.}]
klass = "PRIVATE"
end
What do you think? Any ideas or suggestions would be appreciated.
-Jeff