Class: ONIX::Code
- Includes:
- CodeHelper
- Defined in:
- lib/onix/code.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ Object
code as defined in ONIX documentation codelist.
-
#human ⇒ Object
humanized string (eg: “Digital watermarking” become DigitalWatermarking, “PDF” become Pdf, “BISAC Subject Heading” become BisacSubjectHeading, etc).
Class Method Summary collapse
-
.from_code(code) ⇒ Object
create Code from string ONIX code.
-
.from_human(human) ⇒ Object
create Code from humanized string code.
Methods included from CodeHelper
Methods inherited from Subset
parse, #parse, tag_match, #tag_match, #unsupported
Instance Attribute Details
#code ⇒ Object
code as defined in ONIX documentation codelist
24 25 26 |
# File 'lib/onix/code.rb', line 24 def code @code end |
#human ⇒ Object
humanized string (eg: “Digital watermarking” become DigitalWatermarking, “PDF” become Pdf, “BISAC Subject Heading” become BisacSubjectHeading, etc)
26 27 28 |
# File 'lib/onix/code.rb', line 26 def human @human end |
Class Method Details
.from_code(code) ⇒ Object
create Code from string ONIX code
31 32 33 34 35 36 |
# File 'lib/onix/code.rb', line 31 def self.from_code(code) o=self.new o.code=code o.human=self.hash[code] o end |
.from_human(human) ⇒ Object
create Code from humanized string code
39 40 41 42 43 44 |
# File 'lib/onix/code.rb', line 39 def self.from_human(human) o=self.new o.human=human o.code=self.hash.key(human) o end |