Class: RelatonBib::PersonIdentifier

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_bib/person.rb

Overview

Person identifier.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, value) ⇒ PersonIdentifier



35
36
37
38
39
40
# File 'lib/relaton_bib/person.rb', line 35

def initialize(type, value)
  PersonIdentifierType.check type

  @type  = type
  @value = value
end

Instance Attribute Details

#typeRelatonBib::PersonIdentifierType::ISNI, ...



26
27
28
# File 'lib/relaton_bib/person.rb', line 26

def type
  @type
end

#valueString



29
30
31
# File 'lib/relaton_bib/person.rb', line 29

def value
  @value
end

Instance Method Details

#to_asciibib(prefix = "", count = 1) ⇒ String



55
56
57
58
59
60
61
# File 'lib/relaton_bib/person.rb', line 55

def to_asciibib(prefix = "", count = 1)
  pref = prefix.empty? ? prefix : prefix + "."
  out = count > 1 ? "#{prefix}::\n" : ""
  out += "#{pref}type:: #{type}\n"
  out += "#{pref}value:: #{value}\n"
  out
end

#to_hashHash



48
49
50
# File 'lib/relaton_bib/person.rb', line 48

def to_hash
  { "type" => type, "id" => value }
end

#to_xml(builder) ⇒ Object



43
44
45
# File 'lib/relaton_bib/person.rb', line 43

def to_xml(builder)
  builder.identifier value, type: type
end