Class: Shipping::Package
- Inherits:
-
Object
- Object
- Shipping::Package
- Defined in:
- lib/ups_shipping/package.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#large ⇒ Object
Returns the value of attribute large.
-
#monetary_value ⇒ Object
Returns the value of attribute monetary_value.
-
#weight ⇒ Object
Returns the value of attribute weight.
Instance Method Summary collapse
- #build(xml) ⇒ Object
-
#initialize(options = {}) ⇒ Package
constructor
A new instance of Package.
- #to_xml ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Package
Returns a new instance of Package.
7 8 9 10 11 12 |
# File 'lib/ups_shipping/package.rb', line 7 def initialize(={}) @large = [:large] @weight = [:weight] @description = [:description] @monetary_value = [:monetary_value] end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/ups_shipping/package.rb', line 5 def description @description end |
#large ⇒ Object
Returns the value of attribute large.
5 6 7 |
# File 'lib/ups_shipping/package.rb', line 5 def large @large end |
#monetary_value ⇒ Object
Returns the value of attribute monetary_value.
5 6 7 |
# File 'lib/ups_shipping/package.rb', line 5 def monetary_value @monetary_value end |
#weight ⇒ Object
Returns the value of attribute weight.
5 6 7 |
# File 'lib/ups_shipping/package.rb', line 5 def weight @weight end |
Instance Method Details
#build(xml) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ups_shipping/package.rb', line 14 def build(xml) xml.Package { xml.PackagingType { xml.Code "02" xml.Description "Customer Supplied" } xml.Description @description xml.ReferenceNumber { xml.Code "00" xml.Value "Package" } xml.PackageWeight { xml.UnitOfMeasurement xml.Weight @weight } if @large xml.LargePackageIndicator end } end |
#to_xml ⇒ Object
35 36 37 38 39 40 |
# File 'lib/ups_shipping/package.rb', line 35 def to_xml() builder = Nokogiri::XML::Builder.new do |xml| build(xml) end builder.to_xml end |