class ONIX::Code

Attributes

code[RW]

@!attribute code

@return [String] code as defined in ONIX documentation codelist
human[RW]

@!attribute human

@return [String] humanized string (eg: "Digital watermarking" become DigitalWatermarking, "PDF" become Pdf, "BISAC Subject Heading" become BisacSubjectHeading, etc)

Public Class Methods

from_code(code) click to toggle source

create Code from ONIX code @param [String] code ONIX code @return [Code]

# File lib/onix/code.rb, line 40
def self.from_code(code)
  obj = self.new
  obj.code = code
  obj.human = self.hash[code]
  obj
end
from_human(human) click to toggle source

create Code from human readable code @param [String] human human readable code @return [Code]

# File lib/onix/code.rb, line 50
def self.from_human(human)
  obj = self.new
  obj.human = human
  obj.code = self.hash.key(human)
  unless obj.code
    raise InvalidCodeAlias, [self.to_s, human]
  end
  obj
end

Private Class Methods

hash() click to toggle source
# File lib/onix/code.rb, line 62
def self.hash
  {}
end