Sha256: 85a1e096f3cee9ec09a9c5fd683908f4fe996c84335ac6686332ae683cfb5a4a

Contents?: true

Size: 519 Bytes

Versions: 2

Compression:

Stored size: 519 Bytes

Contents

class Ppl::Format::AddressBook::Urls < Ppl::Format::AddressBook

  attr_writer :table

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

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

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


end

Version data entries

2 entries across 2 versions & 1 rubygems

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