Class: RelatonBib::BiblioNote
Constant Summary
FormattedString::FORMATS
Constants included
from RelatonBib
VERSION
Instance Attribute Summary collapse
#format
#content, #language, #script
Instance Method Summary
collapse
#cleanup, #encode, #scan_xml
#cleanup, #empty?, #encode, #escp, #to_s
Methods included from RelatonBib
array, format_date, grammar_hash, parse_date, parse_yaml
Methods included from Config
#configuration, #configure
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?
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
|