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

Returns a new instance of PersonIdentifier.



134
135
136
137
138
139
# File 'lib/relaton_bib/person.rb', line 134

def initialize(type, value)
  PersonIdentifierType.check type

  @type  = type
  @value = value
end

Instance Attribute Details

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



125
126
127
# File 'lib/relaton_bib/person.rb', line 125

def type
  @type
end

#valueString

Returns:

  • (String)


128
129
130
# File 'lib/relaton_bib/person.rb', line 128

def value
  @value
end

Instance Method Details

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

Parameters:

  • prefix (String) (defaults to: "")
  • count (Integer) (defaults to: 1)

    number of ids

Returns:

  • (String)


154
155
156
157
158
159
160
# File 'lib/relaton_bib/person.rb', line 154

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

Returns:

  • (Hash)


147
148
149
# File 'lib/relaton_bib/person.rb', line 147

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

#to_xml(builder) ⇒ Object

Parameters:

  • builser (Nokogiri::XML::Builder)


142
143
144
# File 'lib/relaton_bib/person.rb', line 142

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