Class: RelatonBib::BibliographicItem::Version

Inherits:
Object
  • Object
show all
Includes:
RelatonBib
Defined in:
lib/relaton_bib/biblio_version.rb

Constant Summary

Constants included from RelatonBib

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RelatonBib

array, format_date, grammar_hash, parse_date, parse_yaml

Methods included from Config

#configuration, #configure

Constructor Details

#initialize(revision_date = nil, draft = nil) ⇒ Version

Returns a new instance of Version.

Parameters:

  • revision_date (String, nil) (defaults to: nil)
  • draft (String, nil) (defaults to: nil)


12
13
14
15
# File 'lib/relaton_bib/biblio_version.rb', line 12

def initialize(revision_date = nil, draft = nil)
  @revision_date = revision_date
  @draft         = draft
end

Instance Attribute Details

#draftString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_bib/biblio_version.rb', line 8

def draft
  @draft
end

#revision_dateString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_bib/biblio_version.rb', line 8

def revision_date
  @revision_date
end

Instance Method Details

#to_asciibib(prefix = "", count = 1) ⇒ String

Parameters:

  • prefix (String) (defaults to: "")

Returns:

  • (String)


35
36
37
38
39
40
41
42
43
# File 'lib/relaton_bib/biblio_version.rb', line 35

def to_asciibib(prefix = "", count = 1)
  pref = prefix.empty? ? prefix : "#{prefix}."
  out = count > 1 ? "#{prefix}version::\n" : ""
  if revision_date
    out += "#{pref}version.revision_date:: #{revision_date}\n"
  end
  out += "#{pref}version.draft:: #{draft}\n" if draft
  out
end

#to_hashHash

Returns:

  • (Hash)


26
27
28
29
30
31
# File 'lib/relaton_bib/biblio_version.rb', line 26

def to_hash
  hash = {}
  hash["revision_date"] = revision_date if revision_date
  hash["draft"] = draft if draft
  hash
end

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


18
19
20
21
22
23
# File 'lib/relaton_bib/biblio_version.rb', line 18

def to_xml(builder)
  builder.version do
    builder.send(:"revision-date", revision_date) if revision_date
    builder.draft draft if draft
  end
end