Class: Temando::Api::Entities::Anything
- Inherits:
-
Object
- Object
- Temando::Api::Entities::Anything
- Defined in:
- lib/temando/api/entities/anything.rb
Instance Method Summary collapse
- #build_xml(xml) ⇒ Object
- #converted_weight ⇒ Object
-
#initialize(anything) ⇒ Anything
constructor
A new instance of Anything.
- #weight_units ⇒ Object
Constructor Details
#initialize(anything) ⇒ Anything
Returns a new instance of Anything.
4 5 6 |
# File 'lib/temando/api/entities/anything.rb', line 4 def initialize(anything) @anything = anything end |
Instance Method Details
#build_xml(xml) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/temando/api/entities/anything.rb', line 24 def build_xml(xml) xml.anything do xml.class_ @anything.shipping_class xml.packagingOptimisation(@anything.packaging_optimization.presence || "N") xml.subclass @anything.shipping_subclass xml.packaging @anything.shipping_packaging xml.palletType @anything.pallet_type unless @anything.pallet_type.nil? xml.palletNature @anything.pallet_nature unless @anything.pallet_nature.nil? xml.qualifierFreightGeneralFragile(@anything.fragile ? 'Y' : 'N') xml.distanceMeasurementType 'Centimetres' xml.weightMeasurementType weight_units xml.length((@anything.length.to_f * 100).ceil) xml.width((@anything.width.to_f * 100).ceil) xml.height((@anything.height.to_f * 100).ceil) xml.weight converted_weight xml.quantity @anything.quantity xml.description @anything.description end end |
#converted_weight ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/temando/api/entities/anything.rb', line 16 def converted_weight if weight_units == 'Grams' then (@anything.weight * 1000).ceil else @anything.weight.ceil end end |
#weight_units ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/temando/api/entities/anything.rb', line 8 def weight_units if @anything.weight < 9.5 then 'Grams' else 'Kilograms' end end |