GithubHelp home page GithubHelp logo

text-vcard's Introduction

NAME

vCard - Read, write, and edit vCards

SYNOPSIS

use vCard;

# create the object
my $vcard = vCard->new;

# these methods load vCard data
# (see method documentation for details)
$vcard->load_file($filename); 
$vcard->load_string($string); 
$vcard->load_hashref($hashref); 

# simple getters/setters
$vcard->full_name('Bruce Banner, PhD');
$vcard->title('Research Scientist');
$vcard->photo('http://example.com/bbanner.gif');

# complex getters/setters
$vcard->phones([
    { type => ['work', 'text'], number => '651-290-1234', preferred => 1 },
    { type => ['home'],         number => '651-290-1111' }
]);
$vcard->email_addresses([
    { type => ['work'], address => '[email protected]' },
    { type => ['home'], address => '[email protected]'      },
]);

# these methods output data in vCard format
my $file   = $vcard->as_file($filename); # writes to $filename
my $string = $vcard->as_string;          # returns a string

DESCRIPTION

A vCard is a digital business card. vCard and vCard::AddressBook provide an API for parsing, editing, and creating vCards.

This module is built on top of Text::vCard. It provides a more intuitive user interface.

To handle an address book with several vCard entries in it, start with vCard::AddressBook and then come back to this module.

Note that the vCard RFC requires version() and full_name(). This module does not check or warn if these conditions have not been met.

ENCODING AND UTF-8

See the 'ENCODING AND UTF-8' section of vCard::AddressBook.

METHODS

load_hashref($hashref)

$hashref should look like this:

full_name    => 'Bruce Banner, PhD',
given_names  => ['Bruce'],
family_names => ['Banner'],
title        => 'Research Scientist',
photo        => 'http://example.com/bbanner.gif',
phones       => [
    { type => ['work'], number => '651-290-1234', preferred => 1 },
    { type => ['cell'], number => '651-290-1111' },
},
addresses => [
    { type => ['work'], ... },
    { type => ['home'], ... },
],
email_addresses => [
    { type => ['work'], address => '[email protected]' },
    { type => ['home'], address => '[email protected]' },
],

Returns $self in case you feel like chaining.

load_file($filename)

Returns $self in case you feel like chaining.

load_string($string)

Returns $self in case you feel like chaining. This method assumes $string is decoded (but not MIME decoded).

as_string()

Returns the vCard as a string.

as_file($filename)

Write data in vCard format to $filename.

Dies if not successful.

SIMPLE GETTERS/SETTERS

These methods accept and return strings.

version()

Version number of the vcard. Defaults to '4.0'

full_name()

A person's entire name as they would like to see it displayed.

title()

A person's position or job.

photo()

This should be a link. Accepts a string or a URI object. This method always returns a URI object.

TODO: handle binary images using the data uri schema

birthday()

timezone()

COMPLEX GETTERS/SETTERS

These methods accept and return array references rather than simple strings.

family_names()

Accepts/returns an arrayref of family names (aka surnames).

given_names()

Accepts/returns an arrayref.

other_names()

Accepts/returns an arrayref of names which don't qualify as family_names or given_names.

honorific_prefixes()

Accepts/returns an arrayref. eg [ 'Dr.' ]

honorific_suffixes()

Accepts/returns an arrayref. eg [ 'Jr.', 'MD' ]

phones()

Accepts/returns an arrayref that looks like:

[
  { type => ['work'], number => '651-290-1234', preferred => 1 },
  { type => ['cell'], number => '651-290-1111' },
]

addresses()

Accepts/returns an arrayref that looks like:

[
  { type => ['work'], street => 'Main St', preferred => 0 },
  { type      => ['home'], 
    pobox     => 1234,
    extended  => 'asdf',
    street    => 'Army St',
    city      => 'Desert Base',
    region    => '',
    post_code => '',
    country   => 'USA',
    preferred => 1,
  },
]

email_addresses()

Accepts/returns an arrayref that looks like:

[
  { type => ['work'], address => '[email protected]' },
  { type => ['home'], address => '[email protected]', preferred => 1 },
]

AUTHOR

Eric Johnson (kablamo), github !at! iijo dot org

ACKNOWLEDGEMENTS

Thanks to Foxtons for making this module possible by donating a significant amount of developer time.

text-vcard's People

Contributors

blairc avatar cpanservice avatar doriantaylor avatar jluis avatar kablamo avatar kni avatar nigelm avatar ranguard avatar szabgab avatar worthmine avatar

Watchers

 avatar  avatar  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.