Sha256: 0e5cad39271064da8686f0e02f37fc9ced0c451f3b2720599aed27373691271a
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
module SimpleShipping # Represents a package which should be sent from {SimpleShipping::Party shipper} # to {SimpleShipping::Party recipient}. # # == Attributes: # * _dimenstion_units_ (:in, :cm). Default is :in. # * _weight_units_ (:kg, :lb). Default is :lb. # * _legth_ (in dimension units) # * _width_ (in dimension units) # * _height_ (in dimension units) # * _weight_ (in weight units) # * _packaging_type_ # # == Packaging type values: # * :envelope # * :your # * :tube # * :pak # * :box # * :box_10kg # * :box_25kg class Package < Abstract::Model attr_accessor :length, :width, :height, :dimension_units attr_accessor :weight, :weight_units, :packaging_type attr_accessor :insured_value, :declared_value validates_presence_of :length, :width, :height, :dimension_units, :if => :custom_package? validates_presence_of :weight, :weight_units validates_inclusion_of :weight_units , :in => [:kg, :lb] validates_inclusion_of :dimension_units, :in => [:in, :cm], :if => :custom_package? validates_inclusion_of :packaging_type , :in => [:envelope, :pak, :tube, :your, :box, :box_10kg, :box_25kg] set_default_values :packaging_type => :your, :weight_units => :lb, :dimension_units => :in # Whether the package is a custom package. def custom_package? packaging_type == :your end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_shipping-0.4.7 | lib/simple_shipping/package.rb |
simple_shipping-0.4.6 | lib/simple_shipping/package.rb |