Class: RelatonBib::Forename
- Inherits:
-
LocalizedString
- Object
- LocalizedString
- RelatonBib::Forename
- Defined in:
- lib/relaton_bib/forename.rb
Constant Summary
Constants included from RelatonBib
Instance Attribute Summary collapse
Attributes inherited from LocalizedString
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(content: nil, language: [], script: [], initial: nil) ⇒ Forename
constructor
Initialize Forename instance.
-
#to_asciibib(pref, count = 1) ⇒ String
Render forename to asciibib.
-
#to_hash ⇒ Hash, String
Render forename to hash.
- #to_s ⇒ Object
-
#to_xml(builder) ⇒ Object
Render forename to XML.
Methods inherited from LocalizedString
#cleanup, #empty?, #encode, #escp
Methods included from RelatonBib
array, format_date, grammar_hash, parse_date, parse_yaml
Methods included from Config
Constructor Details
#initialize(content: nil, language: [], script: [], initial: nil) ⇒ Forename
Initialize Forename instance
14 15 16 17 |
# File 'lib/relaton_bib/forename.rb', line 14 def initialize(content: nil, language: [], script: [], initial: nil) @initial = initial super content, language, script end |
Instance Attribute Details
#initial ⇒ String?
4 5 6 |
# File 'lib/relaton_bib/forename.rb', line 4 def initial @initial end |
Instance Method Details
#==(other) ⇒ Object
19 20 21 |
# File 'lib/relaton_bib/forename.rb', line 19 def ==(other) super && initial == other.initial end |
#to_asciibib(pref, count = 1) ⇒ String
Render forename to asciibib
57 58 59 60 61 62 63 |
# File 'lib/relaton_bib/forename.rb', line 57 def to_asciibib(pref, count = 1) prf = pref.empty? ? pref : "#{pref}." prf += "forename" out = super prf, count out += "#{prf}.initial:: #{initial}\n" if initial out end |
#to_hash ⇒ Hash, String
Render forename to hash
42 43 44 45 46 47 |
# File 'lib/relaton_bib/forename.rb', line 42 def to_hash ls = super hash = ls.is_a?(Hash) ? ls : { "content" => ls } hash["initial"] = initial if initial hash end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/relaton_bib/forename.rb', line 23 def to_s content.nil? ? initial : super end |
#to_xml(builder) ⇒ Object
Render forename to XML
32 33 34 35 |
# File 'lib/relaton_bib/forename.rb', line 32 def to_xml(builder) node = builder.forename { super } node[:initial] = initial if initial end |