We needed to read and write Twitter and Facebook urls, so I followed one of the examples, and created this monkey patch
to write them out:
module Vpim
class Vcard
class Maker
def add_twitter(value)
@card << Vpim::DirectoryInfo::Field.create('X-SOCIALPROFILE', value.to_str, {'type' =>
"twitter"})
end
def add_facebook(value)
@card << Vpim::DirectoryInfo::Field.create('X-SOCIALPROFILE', value.to_str, {'type' =>
"facebook"})
end
end
end
end
Reading them was simpler:
Vpim::Vcard.decode(card_file).map do |card|
contact.facebook_url = card.value("X-SOCIALPROFILE", type="facebook")
contact.twitter_url = card.value("X-SOCIALPROFILE", type="twitter")
end
This follows the format used in OS X's Address Book.app.
Regards,
Scott Williams |