Class: RelatonBib::FullName
- Inherits:
-
Object
- Object
- RelatonBib::FullName
- Defined in:
- lib/relaton_bib/person.rb
Overview
Person’s full name
Instance Attribute Summary collapse
- #additions ⇒ Array<RelatonBib::LocalizedString>
- #completename ⇒ RelatonBib::LocalizedString readonly
- #forenames ⇒ Array<RelatonBib::LocalizedString>
- #initials ⇒ Array<RelatonBib::LocalizedString>
- #prefix ⇒ Array<RelatonBib::LocalizedString>
- #surname ⇒ RelatonBib::LocalizedString
Instance Method Summary collapse
-
#initialize(**args) ⇒ FullName
constructor
A new instance of FullName.
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(**args) ⇒ FullName
Returns a new instance of FullName.
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
#additions ⇒ Array<RelatonBib::LocalizedString>
47 48 49 |
# File 'lib/relaton_bib/person.rb', line 47 def additions @additions end |
#completename ⇒ RelatonBib::LocalizedString (readonly)
53 54 55 |
# File 'lib/relaton_bib/person.rb', line 53 def completename @completename end |
#forenames ⇒ Array<RelatonBib::LocalizedString>
38 39 40 |
# File 'lib/relaton_bib/person.rb', line 38 def forenames @forenames end |
#initials ⇒ Array<RelatonBib::LocalizedString>
41 42 43 |
# File 'lib/relaton_bib/person.rb', line 41 def initials @initials end |
#prefix ⇒ Array<RelatonBib::LocalizedString>
50 51 52 |
# File 'lib/relaton_bib/person.rb', line 50 def prefix @prefix end |
#surname ⇒ RelatonBib::LocalizedString
44 45 46 |
# File 'lib/relaton_bib/person.rb', line 44 def surname @surname end |
Instance Method Details
#to_xml(builder) ⇒ Object
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 |