class Dpd::Shipping::Address
Constants
- VALID_SEX
Attributes
city[RW]
company[RW]
country_code[RW]
email[RW]
name[RW]
phone[RW]
sex[RW]
state[RW]
street[RW]
zip[RW]
Public Class Methods
new(attributes = {})
click to toggle source
# File lib/dpd_shipping/address.rb, line 8 def initialize(attributes = {}) attributes.each do |key, value| setter = :"#{key.to_s}=" if self.respond_to?(setter) self.send(setter, value) end end end
Public Instance Methods
append_to_xml(xml)
click to toggle source
# File lib/dpd_shipping/address.rb, line 31 def append_to_xml(xml) xml.tns :ShipAddress do |xml| xml.tns :Company, company if company? xml.tns :SexCode, sex || :NoSexCode xml.tns :Name, name xml.tns :Street, street xml.tns :ZipCode, zip xml.tns :City, city xml.tns :State, state || "" xml.tns :Country, country_code xml.tns :Phone, phone || "" xml.tns :Mail, email || "" end end
company?()
click to toggle source
# File lib/dpd_shipping/address.rb, line 17 def company? !self.company.blank? end
country_code=(country_code)
click to toggle source
# File lib/dpd_shipping/address.rb, line 26 def country_code=(country_code) raise "Country code must be an ISO-3166 two digit code" unless country_code.length == 2 @country_code = country_code end
sex=(sex)
click to toggle source
# File lib/dpd_shipping/address.rb, line 21 def sex=(sex) raise "Sex must be one of the following: #{VALID_SEX.to_s}" unless VALID_SEX.include? sex @sex = sex end