Class: Ppl::Format::Contact::PostalAddress
- Inherits:
-
Ppl::Format::Contact
- Object
- Ppl::Format::Contact
- Ppl::Format::Contact::PostalAddress
- Defined in:
- lib/ppl/format/contact/postal_address.rb
Instance Attribute Summary collapse
-
#table ⇒ Object
writeonly
Sets the attribute table.
Instance Method Summary collapse
-
#initialize ⇒ PostalAddress
constructor
A new instance of PostalAddress.
- #process(contact) ⇒ Object
Constructor Details
#initialize ⇒ PostalAddress
Returns a new instance of PostalAddress.
5 6 7 |
# File 'lib/ppl/format/contact/postal_address.rb', line 5 def initialize @table = Ppl::Format::Table.new([:label, :value]) end |
Instance Attribute Details
#table=(value) ⇒ Object (writeonly)
Sets the attribute table
3 4 5 |
# File 'lib/ppl/format/contact/postal_address.rb', line 3 def table=(value) @table = value end |
Instance Method Details
#process(contact) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ppl/format/contact/postal_address.rb', line 9 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 |