Class: IsoBibItem::FullName

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

Overview

Person’s full name

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ FullName

Returns a new instance of FullName.



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/iso_bib_item/person.rb', line 31

def initialize(**args)
  unless args[:surname] || args[:completename]
    raise ArgumentError, 'Should be given :surname or :completename'
  end
  @surname      = args[:surname]
  @forenames    = args[:forenames]
  @initials     = args[:initials]
  @additions    = args[:additions]
  @prefix       = args[:prefix]
  @completename = args[:completename]
end

Instance Attribute Details

#additionsArray<IsoBibItem::LocalizedString>



18
19
20
# File 'lib/iso_bib_item/person.rb', line 18

def additions
  @additions
end

#completenameIsoBibItem::LocalizedString (readonly)



24
25
26
# File 'lib/iso_bib_item/person.rb', line 24

def completename
  @completename
end

#forenamesArray<IsoBibItem::LocalizedString>



9
10
11
# File 'lib/iso_bib_item/person.rb', line 9

def forenames
  @forenames
end

#initialsArray<IsoBibItem::LocalizedString>



12
13
14
# File 'lib/iso_bib_item/person.rb', line 12

def initials
  @initials
end

#prefixArray<IsoBibItem::LocalizedString>



21
22
23
# File 'lib/iso_bib_item/person.rb', line 21

def prefix
  @prefix
end

#surnameIsoBibItem::LocalizedString



15
16
17
# File 'lib/iso_bib_item/person.rb', line 15

def surname
  @surname
end

Instance Method Details

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/iso_bib_item/person.rb', line 44

def to_xml(builder)
  builder.name do
    if completename
      builder.completename { completename.to_xml builder }
    else
      builder.prefix { prefix.each { |p| p.to_xml builder } } if prefix
      builder.initial { initials.each { |i| i.to_xml builder } } if initials
      builder.addition { additions.each { |a| a.to_xml builder } } if additions
      builder.surname { surname.to_xml builder }
      builder.forename { forenames.each { |f| f.to_xml builder } } if forenames
    end
  end
end