Class: ONIX::Lists

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/onix/lists.rb

Overview

Builds hashes for all code lists in the ONIX spec.

Use like so:

ONIX::Lists.list(7)
=> { "BB" => "Hardback", ... }

There are also some constants for commonly used lists:

ONIX::Lists::PRODUCT_FORM
=> { "BB" => "Hardback", ... }

Constant Summary collapse

AUDIENCE_CODE =

These are here for backwards compatability with the onix gem <= 0.8.3

ONIX::Lists.audience_code
CONTRIBUTOR_ROLE =
ONIX::Lists.contributor_role
COUNTRY_CODE =
ONIX::Lists.country_code
LANGUAGE_CODE =
ONIX::Lists.language_code
LANGUAGE_ROLE =
ONIX::Lists.language_role
NOTIFICATION_TYPE =
ONIX::Lists.notification_type
PRODUCT_AVAILABILITY =
ONIX::Lists.product_availability
PRODUCT_FORM =
ONIX::Lists.product_form
PRODUCT_FORM_DETAIL =
ONIX::Lists.product_form_detail

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.audience_codeObject

Shortcut to retrieve a common code list



31
32
33
# File 'lib/onix/lists.rb', line 31

def self.audience_code
  self.instance.list(28)
end

.contributor_roleObject

Shortcut to retrieve a common code list



37
38
39
# File 'lib/onix/lists.rb', line 37

def self.contributor_role
  self.instance.list(17)
end

.country_codeObject

Shortcut to retrieve a common code list



43
44
45
# File 'lib/onix/lists.rb', line 43

def self.country_code
  self.instance.list(91)
end

.language_codeObject

Shortcut to retrieve a common code list



49
50
51
# File 'lib/onix/lists.rb', line 49

def self.language_code
  self.instance.list(74)
end

.language_roleObject

Shortcut to retrieve a common code list



55
56
57
# File 'lib/onix/lists.rb', line 55

def self.language_role
  self.instance.list(22)
end

.list(number) ⇒ Object

retrieve a hash with the specified code list

ONIX::Lists.list(7)
=> { "BB" => "Hardback", ... }


25
26
27
# File 'lib/onix/lists.rb', line 25

def self.list(number)
  self.instance.list(number)
end

.notification_typeObject

Shortcut to retrieve a common code list



61
62
63
# File 'lib/onix/lists.rb', line 61

def self.notification_type
  self.instance.list(1)
end

.product_availabilityObject

Shortcut to retrieve a common code list



67
68
69
# File 'lib/onix/lists.rb', line 67

def self.product_availability
  self.instance.list(65)
end

.product_formObject

Shortcut to retrieve a common code list



73
74
75
# File 'lib/onix/lists.rb', line 73

def self.product_form
  self.instance.list(7)
end

.product_form_detailObject

Shortcut to retrieve a common code list



79
80
81
# File 'lib/onix/lists.rb', line 79

def self.product_form_detail
  self.instance.list(78)
end

Instance Method Details

#list(number) ⇒ Object

return a hash with the data for a single code list.

number should be a fixnum specifying the list to retrieve

ONIX::Lists.instance.list(7)
=> { "BB" => "Hardback", ... }


90
91
92
# File 'lib/onix/lists.rb', line 90

def list(number)
  cache[number] ||= build_hash(number)
end