Sha256: 5c4c170be6bff441d3b1ad27c832b277cd32af55c3207cd22293fe038f5f2088

Contents?: true

Size: 594 Bytes

Versions: 10

Compression:

Stored size: 594 Bytes

Contents

class Ppl::Format::AddressBook::OneLine < Ppl::Format::AddressBook

  attr_writer :table

  def initialize
    @table = Ppl::Format::Table.new([:id, :name, :email])
  end

  def process(address_book)
    address_book.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_address.nil?
      email = sprintf("<%s>", contact.email_address)
    end

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

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ppl-1.3.0 lib/ppl/format/address_book/one_line.rb
ppl-1.2.0 lib/ppl/format/address_book/one_line.rb
ppl-1.1.0 lib/ppl/format/address_book/one_line.rb
ppl-1.0.6 lib/ppl/format/address_book/one_line.rb
ppl-1.0.5 lib/ppl/format/address_book/one_line.rb
ppl-1.0.4 lib/ppl/format/address_book/one_line.rb
ppl-1.0.3 lib/ppl/format/address_book/one_line.rb
ppl-1.0.1 lib/ppl/format/address_book/one_line.rb
ppl-1.0.0 lib/ppl/format/address_book/one_line.rb
ppl-0.9.0 lib/ppl/format/address_book/one_line.rb