class ReactiveShipping::PackageItem
Attributes
hs_code[R]
mass[R]
name[R]
options[R]
quantity[R]
sku[R]
value[R]
weight[R]
Public Class Methods
new(name, grams_or_ounces, value, quantity, options = {})
click to toggle source
# File lib/reactive_shipping/package_item.rb, line 5 def initialize(name, grams_or_ounces, value, quantity, options = {}) @name = name imperial = (options[:units] == :imperial) @unit_system = imperial ? :imperial : :metric @weight = grams_or_ounces @weight = Measured::Weight.new(grams_or_ounces, (@unit_system == :imperial ? :oz : :g)) unless @weight.is_a?(Measured::Weight) @value = Package.cents_from(value) @quantity = quantity > 0 ? quantity : 1 @sku = options[:sku] @hs_code = options[:hs_code] @options = options end
Public Instance Methods
grams(options = {})
click to toggle source
# File lib/reactive_shipping/package_item.rb, line 43 def grams(options = {}) weight(options).convert_to(:g).value end
Also aliased as: g
kilograms(options = {})
click to toggle source
# File lib/reactive_shipping/package_item.rb, line 54 def kilograms(options = {}) weight(options).convert_to(:kg).value end
ounces(options = {})
click to toggle source
# File lib/reactive_shipping/package_item.rb, line 38 def ounces(options = {}) weight(options).convert_to(:oz).value end
Also aliased as: oz