Sha256: 1f093aa1e7c5c2cb41d5268ef6904b029d368b48efd4dcfc1e50001ebacafb3d

Contents?: true

Size: 699 Bytes

Versions: 4

Compression:

Stored size: 699 Bytes

Contents

class Ppl::Format::Contact::PostalAddress < Ppl::Format::Contact

  attr_writer :table

  def initialize
    @table = Ppl::Format::Table.new([:label, :value])
  end

  def process(contact)
    address = contact.postal_address

    {
      :street      => "Street",
      :postal_code => "Postal Code",
      :po_box      => "PO box",
      :locality    => "Locality",
      :region      => "Region",
      :country     => "Country",
    }.each do |property, name|
      value = address.send(property)
      next if value.nil? || value == ""
      @table.add_row({
        :label => sprintf("%s:", name),
        :value => address.send(property)
      })
    end

    return @table.to_s
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ppl-1.5.0 lib/ppl/format/contact/postal_address.rb
ppl-1.4.1 lib/ppl/format/contact/postal_address.rb
ppl-1.3.0 lib/ppl/format/contact/postal_address.rb
ppl-1.2.0 lib/ppl/format/contact/postal_address.rb