Sha256: ee15b0525e1480ee5edd069900d0c2122c887854fcdf48985f47da3745b2a6e7

Contents?: true

Size: 613 Bytes

Versions: 2

Compression:

Stored size: 613 Bytes

Contents

class Ppl::Format::AddressBook::EmailAddresses < Ppl::Format::AddressBook

  attr_writer :table

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

    if !contact.email_addresses.empty?
      email_addresses = contact.email_addresses.join(", ")
    end

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


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ppl-1.10.0 lib/ppl/format/address_book/email_addresses.rb
ppl-1.9.0 lib/ppl/format/address_book/email_addresses.rb