Class: RBook::GBIP::Warehouse

Inherits:
Object
  • Object
show all
Defined in:
lib/rbook/gbip/warehouse.rb

Overview

models a warehouse supply detail from the Global Books in Print API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arr) ⇒ Warehouse

Returns a new instance of Warehouse.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rbook/gbip/warehouse.rb', line 12

def initialize(arr)
  raise ArgumentError, "arr must be an array" unless arr.class == Array
  raise ArgumentError, "Invalid number of array elements" unless arr.size == 5

  self.name = arr[0].strip
  self.status = arr[1].strip
  self.onhand = arr[2].to_i
  self.onorder = arr[3].to_i
  tmpdate = arr[4]
  self.updated_at = Date.civil(tmpdate[6,4].to_i, tmpdate[0,2].to_i, tmpdate[3,2].to_i)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/rbook/gbip/warehouse.rb', line 10

def name
  @name
end

#onhandObject

Returns the value of attribute onhand.



10
11
12
# File 'lib/rbook/gbip/warehouse.rb', line 10

def onhand
  @onhand
end

#onorderObject

Returns the value of attribute onorder.



10
11
12
# File 'lib/rbook/gbip/warehouse.rb', line 10

def onorder
  @onorder
end

#statusObject

Returns the value of attribute status.



10
11
12
# File 'lib/rbook/gbip/warehouse.rb', line 10

def status
  @status
end

#updated_atObject

Returns the value of attribute updated_at.



10
11
12
# File 'lib/rbook/gbip/warehouse.rb', line 10

def updated_at
  @updated_at
end