class Ppl::Format::AddressBook::PhoneNumbers

Attributes

table[W]

Public Class Methods

new(colors={}) click to toggle source
# File lib/ppl/format/address_book/phone_numbers.rb, line 5
def initialize(colors={})
  @table = Ppl::Format::Table.new([:id, :phone_numbers], colors)
end

Public Instance Methods

process(address_book) click to toggle source
# File lib/ppl/format/address_book/phone_numbers.rb, line 9
def process(address_book)
  address_book.contacts.each { |contact| add_row(contact) }
  @table.to_s
end

Private Instance Methods

add_row(contact) click to toggle source
# File lib/ppl/format/address_book/phone_numbers.rb, line 17
def add_row(contact)
  @table.add_row({
    :id            => sprintf("%s:", contact.id),
    :phone_numbers => stringify_phone_numbers(contact.phone_numbers)
  })
end
stringify_phone_numbers(phone_numbers) click to toggle source
# File lib/ppl/format/address_book/phone_numbers.rb, line 24
def stringify_phone_numbers(phone_numbers)
  phone_numbers.map { |pn| pn.number }.join(", ")
end