Class: RelatonBib::BibliographicItem::Version
- Includes:
- RelatonBib
- Defined in:
- lib/relaton_bib/biblio_version.rb
Constant Summary
Constants included from RelatonBib
Instance Attribute Summary collapse
- #draft ⇒ Array<String> readonly
- #revision_date ⇒ String, NilClass readonly
Instance Method Summary collapse
-
#initialize(revision_date = nil, draft = []) ⇒ Version
constructor
A new instance of Version.
- #to_asciibib(prefix = "") ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Methods included from RelatonBib
Constructor Details
#initialize(revision_date = nil, draft = []) ⇒ Version
Returns a new instance of Version.
15 16 17 18 |
# File 'lib/relaton_bib/biblio_version.rb', line 15 def initialize(revision_date = nil, draft = []) @revision_date = revision_date @draft = draft end |
Instance Attribute Details
#draft ⇒ Array<String> (readonly)
11 12 13 |
# File 'lib/relaton_bib/biblio_version.rb', line 11 def draft @draft end |
#revision_date ⇒ String, NilClass (readonly)
8 9 10 |
# File 'lib/relaton_bib/biblio_version.rb', line 8 def revision_date @revision_date end |
Instance Method Details
#to_asciibib(prefix = "") ⇒ String
38 39 40 41 42 43 44 45 46 |
# File 'lib/relaton_bib/biblio_version.rb', line 38 def to_asciibib(prefix = "") pref = prefix.empty? ? prefix : prefix + "." out = "" if revision_date out += "#{pref}version.revision_date:: #{revision_date}\n" end draft&.each { |d| out += "#{pref}version.draft:: #{d}\n" } out end |
#to_hash ⇒ Hash
29 30 31 32 33 34 |
# File 'lib/relaton_bib/biblio_version.rb', line 29 def to_hash hash = {} hash["revision_date"] = revision_date if revision_date hash["draft"] = single_element_array(draft) if draft&.any? hash end |
#to_xml(builder) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/relaton_bib/biblio_version.rb', line 21 def to_xml(builder) builder.version do builder.send("revision-date", revision_date) if revision_date draft.each { |d| builder.draft d } end end |