Class: RelatonBib::BiblioNote
- Inherits:
-
FormattedString
- Object
- LocalizedString
- FormattedString
- RelatonBib::BiblioNote
- Defined in:
- lib/relaton_bib/biblio_note.rb
Constant Summary
Constants inherited from FormattedString
Constants included from RelatonBib
Instance Attribute Summary collapse
- #type ⇒ String? readonly
Attributes inherited from FormattedString
Attributes inherited from LocalizedString
Instance Method Summary collapse
-
#initialize(content:, type: nil, language: nil, script: nil, format: nil) ⇒ BiblioNote
constructor
A new instance of BiblioNote.
- #to_asciibib(prefix = "", count = 1) ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Methods inherited from FormattedString
#==, #cleanup, #encode, #scan_xml
Methods inherited from LocalizedString
#==, #cleanup, #empty?, #encode, #escp, #to_s
Methods included from RelatonBib
array, format_date, grammar_hash, parse_date, parse_yaml
Methods included from Config
Constructor Details
#initialize(content:, type: nil, language: nil, script: nil, format: nil) ⇒ BiblioNote
Returns a new instance of BiblioNote.
38 39 40 41 |
# File 'lib/relaton_bib/biblio_note.rb', line 38 def initialize(content:, type: nil, language: nil, script: nil, format: nil) @type = type super content: content, language: language, script: script, format: format end |
Instance Attribute Details
#type ⇒ String? (readonly)
31 32 33 |
# File 'lib/relaton_bib/biblio_note.rb', line 31 def type @type end |
Instance Method Details
#to_asciibib(prefix = "", count = 1) ⇒ String
63 64 65 66 67 68 69 70 |
# File 'lib/relaton_bib/biblio_note.rb', line 63 def to_asciibib(prefix = "", count = 1) pref = prefix.empty? ? prefix : prefix + "." has_attrs = !(type.nil? || type.empty?) out = count > 1 && has_attrs ? "#{pref}biblionote::\n" : "" out += "#{pref}biblionote.type:: #{type}\n" if type out += super "#{pref}biblionote", 1, has_attrs out end |
#to_hash ⇒ Hash
51 52 53 54 55 56 57 58 |
# File 'lib/relaton_bib/biblio_note.rb', line 51 def to_hash hash = super return hash unless type hash = { "content" => hash } if hash.is_a? String hash["type"] = type hash end |
#to_xml(builder) ⇒ Object
44 45 46 47 48 |
# File 'lib/relaton_bib/biblio_note.rb', line 44 def to_xml(builder) xml = builder.note { super } xml[:type] = type if type xml end |