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
-
#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
#to_asciibib(pref, count = 1) ⇒ String
Render forename to asciibib
53 54 55 56 57 58 59 |
# File 'lib/relaton_bib/forename.rb', line 53 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
38 39 40 41 42 43 |
# File 'lib/relaton_bib/forename.rb', line 38 def to_hash ls = super hash = ls.is_a?(Hash) ? ls : { "content" => ls } hash["initial"] = initial if initial hash end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/relaton_bib/forename.rb', line 19 def to_s content.nil? ? initial : super end |
#to_xml(builder) ⇒ Object
Render forename to XML
28 29 30 31 |
# File 'lib/relaton_bib/forename.rb', line 28 def to_xml(builder) node = builder.forename { super } node[:initial] = initial if initial end |