Class: Shipping::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/ups_shipping/package.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options={})
  @large = options[:large]
  @weight = options[:weight]
  @description = options[:description]
  @monetary_value = options[:monetary_value]
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/ups_shipping/package.rb', line 5

def description
  @description
end

#largeObject

Returns the value of attribute large.



5
6
7
# File 'lib/ups_shipping/package.rb', line 5

def large
  @large
end

#monetary_valueObject

Returns the value of attribute monetary_value.



5
6
7
# File 'lib/ups_shipping/package.rb', line 5

def monetary_value
  @monetary_value
end

#weightObject

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_xmlObject



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