Sha256: de60f7c006f879bc45acc8de2f54df0a2d019d4b9683ab978686eb2bb851526c
Contents?: true
Size: 634 Bytes
Versions: 14
Compression:
Stored size: 634 Bytes
Contents
class Ppl::Format::AddressBook::OneLine < Ppl::Format::AddressBook attr_writer :table def initialize(colors={}) @table = Ppl::Format::Table.new([:id, :name, :email], colors) end def process(address_book) address_book.contacts.each { |contact| add_row(contact) } @table.to_s end private def add_row(contact) id = sprintf("%s:", contact.id) name = contact.name email = nil if !contact.email_addresses.empty? email = sprintf("<%s>", contact.email_addresses.first) end @table.add_row({ :id => id, :name => name, :email => email, }) end end
Version data entries
14 entries across 14 versions & 1 rubygems