Sha256: 571e391e215dc9dd12f15ebaed88a9d438227503d134a9ca9f324039d77aa897

Contents?: true

Size: 594 Bytes

Versions: 1

Compression:

Stored size: 594 Bytes

Contents

class Ppl::Format::AddressBook::PhoneNumbers < Ppl::Format::AddressBook

  attr_writer :table

  def initialize
    @table = Ppl::Format::Table.new([:id, :phone_number])
  end

  def process(address_book)
    address_book.contacts.each { |contact| add_row(contact) }
    @table.to_s
  end


  private

  def add_row(contact)
    contact_id   = sprintf("%s:", contact.id)
    phone_number = nil

    if !contact.phone_number.nil?
      phone_number = contact.phone_number
    end

    @table.add_row({
      :id           => contact_id,
      :phone_number => phone_number,
    })
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ppl-1.9.0 lib/ppl/format/address_book/phone_numbers.rb