Sha256: 5b2320da5496cc56158285f648ab4687d23f03e7ab11bd5fc7bb9c8fa848caed

Contents?: true

Size: 757 Bytes

Versions: 5

Compression:

Stored size: 757 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

    if !address.nil?
      {
        :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
    end

    return @table.to_s
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ppl-4.0.5 lib/ppl/format/contact/postal_address.rb
ppl-4.0.3 lib/ppl/format/contact/postal_address.rb
ppl-4.0.2 lib/ppl/format/contact/postal_address.rb
ppl-4.0.1 lib/ppl/format/contact/postal_address.rb
ppl-4.0.0 lib/ppl/format/contact/postal_address.rb