Project

vcardigan

0.06
No release in over 3 years
Low commit activity in last 3 years
There's a lot of open issues
vCardigan is a ruby library for building and parsing vCards that supports both v3.0 and v4.0.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 2.0
 Project Readme

vCardigan

vCardigan is a ruby library for building and parsing vCards that supports both v3.0 and v4.0.

Note: This library is no longer called vCardMate!

Installation

gem install vcardigan

Usage

Creating a vCard

vcard = VCardigan.create(:version => '3.0')

vCard Versions

vCardigan supports vCard versions 3.0 and 4.0. Support for 2.1 is not currently expected. You may pass the version number as an argument to VCardigan.create; the default is 4.0. You may also change the version at any time:

vcard.version '4.0'

Rendering a vCard

vcard.to_s

Adding properties to a vCard

vcard = VCardigan.create
vcard.name 'Strummer', 'Joe'
vcard.fullname 'Joe Strummer'
vcard.photo 'http://strummer.com/joe.jpg', :type => 'uri'
vcard.email 'joe@strummer.com', :type => ['work', 'internet'], :preferred => 1
vcard[:item1].url 'http://strummer.com'
vcard[:item1].label 'Other'
puts vcard

The above would output:

BEGIN:VCARD
VERSION:4.0
N:Strummer;Joe;;;
FN:Joe Strummer
PHOTO;TYPE=uri:http://strummer.com/joe.jpg
EMAIL;TYPE=work,internet;PREF=1:joe@strummer.com
item1.URL:http://strummer.com
item1.LABEL:Other
END:VCARD

Parsing a vCard

Using the above output as data, we could parse it as such:

vcard = VCardigan.parse(data)

vcard.n.first.values # ['strummer', 'joe', '', '', '']
vcard.photo.first.params # { 'type' => 'uri' }
vcard.email.first.params # { 'type' => ['work', 'internet'], 'preferred' => '1' }
vcard[:item1].url.first.value # http://strummer.com