From: Sam Roberts Date: 2003-03-16T07:30:07+09:00 Subject: Re: ANN: vcard 0.1 - a vCard decoding library Ok, I implemented it. I don't want to upload it to RAA right now, because I think asking them to move 3 files from incoming to contrib in a week is a little much, and I'm working on encoding, hooks into the OS X Address Book, and a script to do Address Book lookups from within mutt right now, and thats all stuff I want to release in the next few days. I'll send 0.2 to anybody who's interested. Only change is the addition of the functions described below by Rich. I didn't make things work with symbols yet, because I think its such a good idea that I'm going to make using symbols rather than strings for hash indexing and lookups pervasive, I think it will be much more efficient, particularly because right now I'm .downcase()ing my strings all over the place because comparisons are suppposed to be case-insensitive. Thanks a lot for the feedback. Cheers, Sam Quoteing sroberts@uniserve.com, on Sun, Mar 16, 2003 at 05:05:34AM +0900: > Quoteing rich@infoether.com, on Sun, Mar 16, 2003 at 04:15:57AM +0900: > > One quick recommendation is to use the index method [] as an alias for > > value_of on the VCard object...that way you could do this: > > > > VCDATA =< > BEGIN:VCARD > > VERSION:3.0 > > N:Kilmer;Rich;;; > > FN:Kilmer Rich > > EMAIL;type=HOME:rich@monotheos.com > > EMAIL;type=WORK;type=pref:rich@infoether.com > > END:VCARD > > END > > > > card = Rfc2425::VCard.new(VCDATA) > > puts card["email"] #=> rich@infoether.com > > I thought about it, but didn't because I ran into the "which one do I > return, there can be multiple fields with that name" problem. > > I just looked at RFC2426 in more detail, though, and it appears that > type=pref is allowed for a lot of things that can have multiple > occurences. > > > and possibly accept symbols in addition to strings: > > > > puts card[:email] #=> rich@infoether.com > > > > and perhaps enable a second (optional) param for the type: > > > > puts card[:email, :home] #=> rich@monotheos.com > > > > class VCard > > def [](fieldname, ftype=nil) > > ... > > end > > end > > And if there are multiple matches, you'll always get the first, unless > one of them is pref?(), ok? > > Cheers, > Sam > >