Class: GBIP::Warehouse

Inherits:
Object
  • Object
show all
Defined in:
lib/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)


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

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.



8
9
10
# File 'lib/gbip/warehouse.rb', line 8

def name
  @name
end

#onhandObject

Returns the value of attribute onhand.



8
9
10
# File 'lib/gbip/warehouse.rb', line 8

def onhand
  @onhand
end

#onorderObject

Returns the value of attribute onorder.



8
9
10
# File 'lib/gbip/warehouse.rb', line 8

def onorder
  @onorder
end

#statusObject

Returns the value of attribute status.



8
9
10
# File 'lib/gbip/warehouse.rb', line 8

def status
  @status
end

#updated_atObject

Returns the value of attribute updated_at.



8
9
10
# File 'lib/gbip/warehouse.rb', line 8

def updated_at
  @updated_at
end