Class: FreightKit::Packaging
- Inherits:
-
Object
- Object
- FreightKit::Packaging
- Defined in:
- lib/freight_kit/packaging.rb
Constant Summary collapse
- VALID_TYPES =
%i[ box bundle container crate cylinder drum luggage pail pallet piece roll tote truckload tote ].freeze
- PALLET_TYPES =
%i[crate drum pallet tote].freeze
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #box? ⇒ Boolean
- #box_or_pallet_type ⇒ Object
-
#initialize(type, options = {}) ⇒ Packaging
constructor
Packaging.new(:pallet).
- #pallet? ⇒ Boolean
Constructor Details
#initialize(type, options = {}) ⇒ Packaging
Packaging.new(:pallet)
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/freight_kit/packaging.rb', line 27 def initialize(type, = {}) .symbolize_keys! @options = unless VALID_TYPES.include?(type) raise ArgumentError, "Package#new: `type` should be one of #{VALID_TYPES.join(", ")}" end @type = type end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
24 25 26 |
# File 'lib/freight_kit/packaging.rb', line 24 def type @type end |
Instance Method Details
#box? ⇒ Boolean
38 39 40 |
# File 'lib/freight_kit/packaging.rb', line 38 def box? @box ||= BOX_TYPES.include?(@type) end |
#box_or_pallet_type ⇒ Object
46 47 48 49 50 |
# File 'lib/freight_kit/packaging.rb', line 46 def box_or_pallet_type return :pallet if pallet? box? ? :box : nil end |
#pallet? ⇒ Boolean
42 43 44 |
# File 'lib/freight_kit/packaging.rb', line 42 def pallet? @pallet ||= PALLET_TYPES.include?(@type) end |