Sha256: 4da71df3bc873aaaeaf1bf9341d7d27b05fd04db87f8aac92e9ffc10628b16b7

Contents?: true

Size: 613 Bytes

Versions: 18

Compression:

Stored size: 613 Bytes

Contents

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

  attr_writer :table

  def initialize(colors={})
    @table = Ppl::Format::Table.new([:id, :phone_numbers], colors)
  end

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


  private

  def add_row(contact)
    @table.add_row({
      :id            => sprintf("%s:", contact.id),
      :phone_numbers => stringify_phone_numbers(contact.phone_numbers)
    })
  end

  def stringify_phone_numbers(phone_numbers)
    phone_numbers.map { |pn| pn.number }.join(", ")
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ppl-3.0.1 lib/ppl/format/address_book/phone_numbers.rb
ppl-3.0.0 lib/ppl/format/address_book/phone_numbers.rb
ppl-2.4.1 lib/ppl/format/address_book/phone_numbers.rb
ppl-2.4.0 lib/ppl/format/address_book/phone_numbers.rb
ppl-2.3.3 lib/ppl/format/address_book/phone_numbers.rb
ppl-2.3.2 lib/ppl/format/address_book/phone_numbers.rb
ppl-2.3.1 lib/ppl/format/address_book/phone_numbers.rb
ppl-2.3.0 lib/ppl/format/address_book/phone_numbers.rb
ppl-2.2.0 lib/ppl/format/address_book/phone_numbers.rb
ppl-2.1.0 lib/ppl/format/address_book/phone_numbers.rb
ppl-2.0.0 lib/ppl/format/address_book/phone_numbers.rb
ppl-1.25.0 lib/ppl/format/address_book/phone_numbers.rb
ppl-1.24.0 lib/ppl/format/address_book/phone_numbers.rb
ppl-1.23.0 lib/ppl/format/address_book/phone_numbers.rb
ppl-1.22.2 lib/ppl/format/address_book/phone_numbers.rb
ppl-1.22.1 lib/ppl/format/address_book/phone_numbers.rb
ppl-1.22.0 lib/ppl/format/address_book/phone_numbers.rb
ppl-1.21.0 lib/ppl/format/address_book/phone_numbers.rb