Class: RelatonBib::FullName

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_bib/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.

Parameters:



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/relaton_bib/person.rb', line 61

def initialize(**args)
  unless args[:surname] || args[:completename]
    raise ArgumentError, "Should be given :surname or :completename"
  end

  @surname      = args[:surname]
  @forenames    = args.fetch :forenames, []
  @initials     = args.fetch :initials, []
  @additions    = args.fetch :additions, []
  @prefix       = args.fetch :prefix, []
  @completename = args[:completename]
end

Instance Attribute Details

#additionsArray<RelatonBib::LocalizedString>

Returns:



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

def additions
  @additions
end

#completenameRelatonBib::LocalizedString (readonly)



53
54
55
# File 'lib/relaton_bib/person.rb', line 53

def completename
  @completename
end

#forenamesArray<RelatonBib::LocalizedString>

Returns:



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

def forenames
  @forenames
end

#initialsArray<RelatonBib::LocalizedString>

Returns:



41
42
43
# File 'lib/relaton_bib/person.rb', line 41

def initials
  @initials
end

#prefixArray<RelatonBib::LocalizedString>

Returns:



50
51
52
# File 'lib/relaton_bib/person.rb', line 50

def prefix
  @prefix
end

#surnameRelatonBib::LocalizedString



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

def surname
  @surname
end

Instance Method Details

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/relaton_bib/person.rb', line 75

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