Class: Cacofonix::Lists
- Inherits:
-
Object
- Object
- Cacofonix::Lists
- Includes:
- Singleton
- Defined in:
- lib/cacofonix/core/lists.rb
Overview
Builds hashes for all code lists in the ONIX spec.
Use like so:
Cacofonix::Lists.list(7)
=> { "BB" => "Hardback", ... }
There are also some constants for commonly used lists:
Cacofonix::Lists::PRODUCT_FORM
=> { "BB" => "Hardback", ... }
Constant Summary collapse
- AUDIENCE_CODE =
These are here for backwards compatability with the onix gem <= 0.8.3
Cacofonix::Lists.audience_code
- CONTRIBUTOR_ROLE =
Cacofonix::Lists.contributor_role
- COUNTRY_CODE =
Cacofonix::Lists.country_code
- LANGUAGE_CODE =
Cacofonix::Lists.language_code
- LANGUAGE_ROLE =
Cacofonix::Lists.language_role
- NOTIFICATION_TYPE =
Cacofonix::Lists.notification_type
- PRODUCT_AVAILABILITY =
Cacofonix::Lists.product_availability
- PRODUCT_FORM =
Cacofonix::Lists.product_form
- PRODUCT_FORM_DETAIL =
Cacofonix::Lists.product_form_detail
Class Method Summary collapse
-
.audience_code ⇒ Object
Shortcut to retrieve a common code list.
-
.contributor_role ⇒ Object
Shortcut to retrieve a common code list.
-
.country_code ⇒ Object
Shortcut to retrieve a common code list.
-
.language_code ⇒ Object
Shortcut to retrieve a common code list.
-
.language_role ⇒ Object
Shortcut to retrieve a common code list.
-
.list(number) ⇒ Object
retrieve a hash with the specified code list.
-
.notification_type ⇒ Object
Shortcut to retrieve a common code list.
-
.product_availability ⇒ Object
Shortcut to retrieve a common code list.
-
.product_form ⇒ Object
Shortcut to retrieve a common code list.
-
.product_form_detail ⇒ Object
Shortcut to retrieve a common code list.
Instance Method Summary collapse
-
#list(number) ⇒ Object
Return a hash with the data for a single code list.
Class Method Details
.audience_code ⇒ Object
Shortcut to retrieve a common code list
44 45 46 |
# File 'lib/cacofonix/core/lists.rb', line 44 def self.audience_code self.instance.list(28) end |
.contributor_role ⇒ Object
Shortcut to retrieve a common code list
50 51 52 |
# File 'lib/cacofonix/core/lists.rb', line 50 def self.contributor_role self.instance.list(17) end |
.country_code ⇒ Object
Shortcut to retrieve a common code list
56 57 58 |
# File 'lib/cacofonix/core/lists.rb', line 56 def self.country_code self.instance.list(91) end |
.language_code ⇒ Object
Shortcut to retrieve a common code list
62 63 64 |
# File 'lib/cacofonix/core/lists.rb', line 62 def self.language_code self.instance.list(74) end |
.language_role ⇒ Object
Shortcut to retrieve a common code list
68 69 70 |
# File 'lib/cacofonix/core/lists.rb', line 68 def self.language_role self.instance.list(22) end |
.list(number) ⇒ Object
retrieve a hash with the specified code list
Cacofonix::Lists.list(7)
=> { "BB" => "Hardback", ... }
25 26 27 |
# File 'lib/cacofonix/core/lists.rb', line 25 def self.list(number) self.instance.list(number) end |
.notification_type ⇒ Object
Shortcut to retrieve a common code list
74 75 76 |
# File 'lib/cacofonix/core/lists.rb', line 74 def self.notification_type self.instance.list(1) end |
.product_availability ⇒ Object
Shortcut to retrieve a common code list
80 81 82 |
# File 'lib/cacofonix/core/lists.rb', line 80 def self.product_availability self.instance.list(65) end |
.product_form ⇒ Object
Shortcut to retrieve a common code list
86 87 88 |
# File 'lib/cacofonix/core/lists.rb', line 86 def self.product_form self.instance.list(7) end |
.product_form_detail ⇒ Object
Shortcut to retrieve a common code list
92 93 94 |
# File 'lib/cacofonix/core/lists.rb', line 92 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:
Cacofonix::Lists.instance.list(7)
=> { "BB" => "Hardback", ... }
36 37 38 39 40 |
# File 'lib/cacofonix/core/lists.rb', line 36 def list(number) raise "Invalid list number: #{number}" unless number.to_s.match(/^\d+$/) require File.join("cacofonix", "codelists", number.to_s.rjust(3, "0")) eval("Cacofonix::CodeLists::LIST_#{number}") end |