Class: ONIX::Code

Inherits:
Subset show all
Includes:
CodeHelper
Defined in:
lib/onix/code.rb

Direct Known Subclasses

CodeFromYaml, ONIX21::CodeFromYaml

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from CodeHelper

#onix, #parse

Methods inherited from Subset

parse, #parse, tag_match, #tag_match, #unsupported

Instance Attribute Details

#codeObject

code as defined in ONIX documentation codelist



24
25
26
# File 'lib/onix/code.rb', line 24

def code
  @code
end

#humanObject

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