Class: Dhl::Intraship::Address
- Inherits:
-
Object
- Object
- Dhl::Intraship::Address
- Defined in:
- lib/dhl-intraship/address.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#contact_person ⇒ Object
Returns the value of attribute contact_person.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#email ⇒ Object
Returns the value of attribute email.
-
#house_number ⇒ Object
Returns the value of attribute house_number.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#street ⇒ Object
Returns the value of attribute street.
-
#street_additional ⇒ Object
Returns the value of attribute street_additional.
-
#zip ⇒ Object
Returns the value of attribute zip.
Instance Method Summary collapse
- #append_to_xml(xml) ⇒ Object
- #company? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Address
constructor
A new instance of Address.
Constructor Details
#initialize(attributes = {}) ⇒ Address
Returns a new instance of Address.
7 8 9 10 11 12 13 14 |
# File 'lib/dhl-intraship/address.rb', line 7 def initialize(attributes = {}) attributes.each do |key, value| setter = :"#{key.to_s}=" if self.respond_to?(setter) self.send(setter, value) end end end |
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city.
4 5 6 |
# File 'lib/dhl-intraship/address.rb', line 4 def city @city end |
#contact_person ⇒ Object
Returns the value of attribute contact_person.
4 5 6 |
# File 'lib/dhl-intraship/address.rb', line 4 def contact_person @contact_person end |
#country_code ⇒ Object
Returns the value of attribute country_code.
4 5 6 |
# File 'lib/dhl-intraship/address.rb', line 4 def country_code @country_code end |
#email ⇒ Object
Returns the value of attribute email.
4 5 6 |
# File 'lib/dhl-intraship/address.rb', line 4 def email @email end |
#house_number ⇒ Object
Returns the value of attribute house_number.
4 5 6 |
# File 'lib/dhl-intraship/address.rb', line 4 def house_number @house_number end |
#phone ⇒ Object
Returns the value of attribute phone.
4 5 6 |
# File 'lib/dhl-intraship/address.rb', line 4 def phone @phone end |
#street ⇒ Object
Returns the value of attribute street.
4 5 6 |
# File 'lib/dhl-intraship/address.rb', line 4 def street @street end |
#street_additional ⇒ Object
Returns the value of attribute street_additional.
4 5 6 |
# File 'lib/dhl-intraship/address.rb', line 4 def street_additional @street_additional end |
#zip ⇒ Object
Returns the value of attribute zip.
4 5 6 |
# File 'lib/dhl-intraship/address.rb', line 4 def zip @zip end |
Instance Method Details
#append_to_xml(xml) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dhl-intraship/address.rb', line 25 def append_to_xml(xml) xml.Company do |xml| company_xml(xml) end xml.Address do |xml| xml.cis(:streetName, street) xml.cis(:streetNumber, house_number) xml.cis(:careOfName, street_additional) unless street_additional.blank? xml.cis(:Zip) do |xml| if country_code == 'DE' xml.cis(:germany, zip) elsif ['GB','UK'].include?(country_code) xml.cis(:england, zip) else xml.cis(:other, zip) end end xml.cis(:city, city) xml.cis(:Origin) do |xml| xml.cis(:countryISOCode, country_code) end end xml.Communication do |xml| xml.cis(:phone, self.phone) unless self.phone.blank? xml.cis(:email, self.email) unless self.email.blank? xml.cis(:contactPerson, contact_person.blank? ? "" : contact_person) end end |
#company? ⇒ Boolean
16 17 18 |
# File 'lib/dhl-intraship/address.rb', line 16 def company? !self.company.blank? end |