Class: Physical::Item

Inherits:
Cuboid
  • Object
show all
Defined in:
lib/physical/item.rb

Overview

Represents a physical item which can be packed into a box.

Constant Summary collapse

DEFAULT_LENGTH =

The default dimensions of this item when unspecified

0

Instance Attribute Summary collapse

Attributes inherited from Cuboid

#dimensions, #height, #id, #length, #properties, #weight, #width

Instance Method Summary collapse

Methods inherited from Cuboid

#==, #density, #volume

Constructor Details

#initialize(**kwargs) ⇒ Item

Returns a new instance of Item.

Parameters:

  • kwargs (Hash)

    ID, dimensions, weight, and properties

Options Hash (**kwargs):

  • :id (String)

    a unique identifier for this item

  • :cost (Money)

    the cost of this item

  • :sku (String)

    the SKU for this item

  • :description (String)

    a description for this item

  • :dimensions (Array<Measured::Length>)

    the length, width, and height of this item

  • :weight (Measured::Weight)

    the weight of this item

  • :properties (Hash)

    additional custom properties for this item



29
30
31
32
33
34
# File 'lib/physical/item.rb', line 29

def initialize(**kwargs)
  @cost = Types::Money.optional[kwargs.delete(:cost)]
  @sku = kwargs.delete(:sku)
  @description = kwargs.delete(:description)
  super(**kwargs)
end

Instance Attribute Details

#costMoney (readonly)

The cost for this item

Returns:

  • (Money)


11
12
13
# File 'lib/physical/item.rb', line 11

def cost
  @cost
end

#descriptionString (readonly)

A description for this item

Returns:

  • (String)


19
20
21
# File 'lib/physical/item.rb', line 19

def description
  @description
end

#skuString (readonly)

The SKU for this item

Returns:

  • (String)


15
16
17
# File 'lib/physical/item.rb', line 15

def sku
  @sku
end