Sha256: 6b5191442ff02267f52f42eb49b75cd5139406a2b16a81fb3bdccae56aefdb8a

Contents?: true

Size: 1.1 KB

Versions: 24

Compression:

Stored size: 1.1 KB

Contents

require 'vpim/vcard'

ORIGINAL =<<'---'
BEGIN:VCARD
VERSION:3.0
FN:Jimmy Death
N:Death;Jimmy;;Dr.;
TEL:+416 123 1111
TEL;type=home,pref:+416 123 2222
TEL;type=work,fax:+416+123+3333
EMAIL;type=work:drdeath@work.com
EMAIL;type=pref:drdeath@home.net
NOTE:Do not call.
END:VCARD
---

original = Vpim::Vcard.decode(ORIGINAL).first

puts original

modified = Vpim::Vcard::Maker.make2 do |maker|
  # Set the fullname field to use family-given name order.
  maker.name do |n|
    n.fullname = "#{original.name.family} #{original.name.given}"
  end

  # Copy original fields, with some changes:
  # - set only work email addresses and telephone numbers to be preferred.
  # - don't copy notes
  maker.copy(original) do |field|
    if field.name? 'EMAIL'
      field = field.copy
      field.pref = field.type? 'work'
    end
    if field.name? 'TEL'
      field = field.copy
      field.pref = field.type? 'work'
    end
    if field.name? 'NOTE'
      field = nil
    end
    field
  end
end

puts '---'
puts modified

Vpim::Vcard::Maker.make2(modified) do |maker|
  maker.nickname = "Your Last Friend"
end

puts '---'
puts modified

Version data entries

24 entries across 24 versions & 11 rubygems

Version Path
vpim-24.2.20 samples/ex_cpvcard.rb
fraser-vpim-0.658 samples/ex_cpvcard.rb
fraser-vpim-0.659 samples/ex_cpvcard.rb
fraser-vpim-rails-0.658 samples/ex_cpvcard.rb
fraser-vpim-rails-0.659 samples/ex_cpvcard.rb
xing-vpim-0.658.1 samples/ex_cpvcard.rb
vpim-13.11.11 samples/ex_cpvcard.rb
vpim2-0.0.1 samples/ex_cpvcard.rb
vpim-rails-reinteractive-0.7 samples/ex_cpvcard.rb
vpim-rails-0.665 samples/ex_cpvcard.rb
thoughtafter-vpim-0.7.0.1 samples/ex_cpvcard.rb
vpim-rails-0.664 samples/ex_cpvcard.rb
vpim-rails-0.663 samples/ex_cpvcard.rb
vpim-rails-0.662 samples/ex_cpvcard.rb
scashin133-vpim-9.4.0 samples/ex_cpvcard.rb
vpim-rails-0.661 samples/ex_cpvcard.rb
mumboe-vpim-0.7 samples/ex_cpvcard.rb
mumboe-vpim-0.695 samples/ex_cpvcard.rb
fairtilizer-vpim-0.695 samples/ex_cpvcard.rb
vpim-0.602 samples/ex_cpvcard.rb