Class: Ppl::Adapter::Vcard::Vpim

Inherits:
Object
  • Object
show all
Defined in:
lib/ppl/adapter/vcard/vpim.rb

Constant Summary collapse

@@postal_address_property_map =
{
  :street     => :street,
  :postalcode => :postal_code,
  :pobox      => :po_box,
  :country    => :country,
  :region     => :region,
  :locality   => :locality,
  :preferred  => :preferred,
}

Instance Method Summary collapse

Instance Method Details

#decode(string) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ppl/adapter/vcard/vpim.rb', line 30

def decode(string)
  vcard   = Vpim::Vcard.decode(string).first
  contact = Ppl::Entity::Contact.new
  decode_birthday(vcard, contact)
  decode_email_addresses(vcard, contact)
  decode_phone_numbers(vcard, contact)
  decode_postal_addresses(vcard, contact)
  decode_nicknames(vcard, contact)
  decode_organizations(vcard, contact)
  decode_name(vcard, contact)
  decode_urls(vcard, contact)
  return contact
end

#encode(contact) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ppl/adapter/vcard/vpim.rb', line 16

def encode(contact)
  vcard = Vpim::Vcard::Maker.make2 do |maker|
    encode_birthday(contact, maker)
    encode_name(contact, maker)
    encode_email_addresses(contact, maker)
    encode_phone_numbers(contact, maker)
    encode_nicknames(contact, maker)
    encode_organizations(contact, maker)
    encode_postal_addresses(contact, maker)
    encode_urls(contact, maker)
  end
  vcard.to_s
end