Class: GBIP::Title

Inherits:
Object
  • Object
show all
Defined in:
lib/gbip/title.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) ⇒ Title

Returns a new instance of Title.

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gbip/title.rb', line 17

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

  self.market = arr[2].strip
  self.title = arr[3].strip
  self.isbn = RBook::ISBN.convert_to_isbn13(arr[4].strip) || arr[4].strip
  self.binding = arr[5].strip
  self.status = arr[6].strip
  self.edition = arr[7].strip
  self.contributor = arr[8].strip
  self.publisher = arr[9].strip
  self.publication_date = arr[10].strip
  self.rrp = BigDecimal.new(arr[11].strip)
  self.country = arr[12].strip
  self.pubcode = arr[13].strip
  self.currency = arr[14].strip
  self.bowker_subject = arr[15].strip
  self.bisac_subject = arr[16].strip
  self.child_subject = arr[17].strip
  self.bic_subject = arr[18].strip
  self.supplier = arr[19].strip
  self.suppliers_with_stock = arr[20].strip

  @warehouses = []
end

Instance Attribute Details

#bic_subjectObject

Returns the value of attribute bic_subject.



14
15
16
# File 'lib/gbip/title.rb', line 14

def bic_subject
  @bic_subject
end

#bindingObject

Returns the value of attribute binding.



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

def binding
  @binding
end

#bisac_subjectObject

Returns the value of attribute bisac_subject.



14
15
16
# File 'lib/gbip/title.rb', line 14

def bisac_subject
  @bisac_subject
end

#bowker_subjectObject

Returns the value of attribute bowker_subject.



13
14
15
# File 'lib/gbip/title.rb', line 13

def bowker_subject
  @bowker_subject
end

#child_subjectObject

Returns the value of attribute child_subject.



14
15
16
# File 'lib/gbip/title.rb', line 14

def child_subject
  @child_subject
end

#contributorObject

Returns the value of attribute contributor.



11
12
13
# File 'lib/gbip/title.rb', line 11

def contributor
  @contributor
end

#countryObject

Returns the value of attribute country.



13
14
15
# File 'lib/gbip/title.rb', line 13

def country
  @country
end

#currencyObject

Returns the value of attribute currency.



13
14
15
# File 'lib/gbip/title.rb', line 13

def currency
  @currency
end

#editionObject

Returns the value of attribute edition.



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

def edition
  @edition
end

#isbnObject

Returns the value of attribute isbn.



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

def isbn
  @isbn
end

#marketObject

Returns the value of attribute market.



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

def market
  @market
end

#pubcodeObject

Returns the value of attribute pubcode.



13
14
15
# File 'lib/gbip/title.rb', line 13

def pubcode
  @pubcode
end

#publication_dateObject

Returns the value of attribute publication_date.



11
12
13
# File 'lib/gbip/title.rb', line 11

def publication_date
  @publication_date
end

#publisherObject

Returns the value of attribute publisher.



11
12
13
# File 'lib/gbip/title.rb', line 11

def publisher
  @publisher
end

#rrpObject

Returns the value of attribute rrp.



12
13
14
# File 'lib/gbip/title.rb', line 12

def rrp
  @rrp
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#supplierObject

Returns the value of attribute supplier.



12
13
14
# File 'lib/gbip/title.rb', line 12

def supplier
  @supplier
end

#suppliers_with_stockObject

Returns the value of attribute suppliers_with_stock.



12
13
14
# File 'lib/gbip/title.rb', line 12

def suppliers_with_stock
  @suppliers_with_stock
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#warehousesObject

Returns the value of attribute warehouses.



15
16
17
# File 'lib/gbip/title.rb', line 15

def warehouses
  @warehouses
end

Instance Method Details

#to_yamlObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/gbip/title.rb', line 44

def to_yaml
  YAML.dump(:status    => self.status,
            :pubdate   => self.publication_date,
            :binding   => self.binding,
            :publisher => self.publisher,
            :contributor => self.contributor,
            :isbn      => self.isbn,
            :edition   => self.edition,
            :market    => self.market,
            :rrp       => self.rrp.to_s("F"),
            :title     => self.title,
            :country   => self.country,
            :pubcode   => self.pubcode,
            :currency  => self.currency,
            :bowker_subject => self.bowker_subject,
            :bisac_subject  => self.bisac_subject,
            :child_subject  => self.child_subject,
            :bic_subject    => self.bic_subject,
            :supplier  => self.supplier,
            :suppliers_with_stock => self.suppliers_with_stock
           )
end