Class: Shipping::Address
- Inherits:
-
Object
- Object
- Shipping::Address
- Defined in:
- lib/ups_shipping/address.rb
Constant Summary collapse
- ADDRESS_TYPES =
%w{residential commercial po_box}
Instance Attribute Summary collapse
-
#address_lines ⇒ Object
Returns the value of attribute address_lines.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#state ⇒ Object
Returns the value of attribute state.
-
#type ⇒ Object
Returns the value of attribute type.
-
#zip ⇒ Object
Returns the value of attribute zip.
Instance Method Summary collapse
- #build(xml) ⇒ Object
-
#initialize(options = {}) ⇒ Address
constructor
A new instance of Address.
- #to_xml ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Address
Returns a new instance of Address.
8 9 10 11 12 13 14 15 |
# File 'lib/ups_shipping/address.rb', line 8 def initialize(={}) @address_lines = [:address_lines] @city = [:city] @state = [:state] @zip = [:zip] @country = [:country] @type = [:type] end |
Instance Attribute Details
#address_lines ⇒ Object
Returns the value of attribute address_lines.
6 7 8 |
# File 'lib/ups_shipping/address.rb', line 6 def address_lines @address_lines end |
#city ⇒ Object
Returns the value of attribute city.
6 7 8 |
# File 'lib/ups_shipping/address.rb', line 6 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
6 7 8 |
# File 'lib/ups_shipping/address.rb', line 6 def country @country end |
#state ⇒ Object
Returns the value of attribute state.
6 7 8 |
# File 'lib/ups_shipping/address.rb', line 6 def state @state end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/ups_shipping/address.rb', line 6 def type @type end |
#zip ⇒ Object
Returns the value of attribute zip.
6 7 8 |
# File 'lib/ups_shipping/address.rb', line 6 def zip @zip end |
Instance Method Details
#build(xml) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/ups_shipping/address.rb', line 17 def build(xml) xml.Address { xml.AddressLine1 @address_lines[0] xml.City @city xml.StateProvinceCode @state xml.PostalCode @zip xml.CountryCode @country } end |
#to_xml ⇒ Object
27 28 29 30 31 32 |
# File 'lib/ups_shipping/address.rb', line 27 def to_xml() builder = Nokogiri::XML::Builder.new do |xml| build(xml) end builder.to_xml end |