From: Richard Kilmer Date: 2003-03-16T05:34:48+09:00 Subject: Re: ANN: vcard 0.1 - a vCard decoding library I think the index method [] returning the preferred field (if pref is specified) or the first (of many) is acceptable. I would not use the index method if I wanted a full enumeration (and you provide methods for that) but for quick access. If you had two work email addresses (and none were preferred) I think as long as I get one, I would be happy. if vcard[:email] ...send email end I would not want to have to always check for an Array vs. a String thought...that would make code kind of messy. -rich On Saturday, March 15, 2003, at 03:18 PM, Alan Chen wrote: > > Well, you could always return an array. > puts card[:email] #=> [ rich@infoether.com ] > > > On Sun, Mar 16, 2003 at 05:05:34AM +0900, Sam Roberts wrote: >> 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. > > > -- > Alan Chen > Digikata Computing > http://digikata.com > >