Git Product home page Git Product logo

vcardigan's Introduction

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 '[email protected]', :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:[email protected]
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

vcardigan's People

Contributors

mlmorg avatar carmi avatar

Watchers

Irvin Fan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.