Sha256: 6c1304d5f7a75b114de14f1af4ad11e963d8f6a066d688ffe74202a3bd751a5b

Contents?: true

Size: 969 Bytes

Versions: 1

Compression:

Stored size: 969 Bytes

Contents

class Ppl::Format::Custom::Contact < Ppl::Format::Custom

  format :n do |anything|
    "\n"
  end

  format :i do |contact|
    contact.id
  end

  format :N do |contact|
    contact.name
  end

  format :a do |contact|
    contact.age(Date.today)
  end

  format :b do |contact|
    unless contact.birthday.nil?
      contact.birthday.strftime("%Y-%m-%d")
    end
  end

  format :k do |contact|
    contact.nicknames.first
  end

  format :e do |contact|
    preferred = contact.email_addresses.find { |e| e.preferred }
    first = contact.email_addresses.first
    if !preferred.nil?
      preferred.address
    elsif !first.nil?
      first.address
    end
  end

  format :o do |contact|
    contact.organizations.first
  end

  format :p do |contact|
    preferred = contact.phone_numbers.find { |p| p.preferred }
    first = contact.phone_numbers.first
    if !preferred.nil?
      preferred.number
    elsif !first.nil?
      first.number
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ppl-1.25.0 lib/ppl/format/custom/contact.rb