Sha256: 47f80964649ab15d4fd5abf7a4e1d2b2343cc0fab10df3b66707359d42b430cd

Contents?: true

Size: 530 Bytes

Versions: 27

Compression:

Stored size: 530 Bytes

Contents

class Ppl::Format::AddressBook::Names < Ppl::Format::AddressBook

  attr_writer :table

  def initialize(colors={})
    @table = Ppl::Format::Table.new([:id, :name], 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 = nil

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

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


end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
ppl-1.18.0 lib/ppl/format/address_book/names.rb
ppl-1.17.2 lib/ppl/format/address_book/names.rb
ppl-1.17.1 lib/ppl/format/address_book/names.rb
ppl-1.17.0 lib/ppl/format/address_book/names.rb
ppl-1.16.0 lib/ppl/format/address_book/names.rb
ppl-1.15.1 lib/ppl/format/address_book/names.rb
ppl-1.15.0 lib/ppl/format/address_book/names.rb