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

Version Path
ppl-1.23.0 lib/ppl/format/address_book/one_line.rb
ppl-1.22.2 lib/ppl/format/address_book/one_line.rb
ppl-1.22.1 lib/ppl/format/address_book/one_line.rb
ppl-1.22.0 lib/ppl/format/address_book/one_line.rb
ppl-1.21.0 lib/ppl/format/address_book/one_line.rb
ppl-1.20.0 lib/ppl/format/address_book/one_line.rb
ppl-1.19.0 lib/ppl/format/address_book/one_line.rb
ppl-1.18.0 lib/ppl/format/address_book/one_line.rb
ppl-1.17.2 lib/ppl/format/address_book/one_line.rb
ppl-1.17.1 lib/ppl/format/address_book/one_line.rb
ppl-1.17.0 lib/ppl/format/address_book/one_line.rb
ppl-1.16.0 lib/ppl/format/address_book/one_line.rb
ppl-1.15.1 lib/ppl/format/address_book/one_line.rb
ppl-1.15.0 lib/ppl/format/address_book/one_line.rb