Class: RelatonBib::Validity
Constant Summary collapse
- FORMAT =
"%Y-%m-%d %H:%M".freeze
Instance Attribute Summary collapse
- #begins ⇒ Time? readonly
- #ends ⇒ Time? readonly
- #revision ⇒ Time? readonly
Instance Method Summary collapse
-
#initialize(begins: nil, ends: nil, revision: nil) ⇒ Validity
constructor
A new instance of Validity.
- #to_asciibib(prefix = "") ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(begins: nil, ends: nil, revision: nil) ⇒ Validity
Returns a new instance of Validity.
17 18 19 20 21 |
# File 'lib/relaton_bib/validity.rb', line 17 def initialize(begins: nil, ends: nil, revision: nil) @begins = begins @ends = ends @revision = revision end |
Instance Attribute Details
#begins ⇒ Time? (readonly)
6 7 8 |
# File 'lib/relaton_bib/validity.rb', line 6 def begins @begins end |
#ends ⇒ Time? (readonly)
9 10 11 |
# File 'lib/relaton_bib/validity.rb', line 9 def ends @ends end |
#revision ⇒ Time? (readonly)
12 13 14 |
# File 'lib/relaton_bib/validity.rb', line 12 def revision @revision end |
Instance Method Details
#to_asciibib(prefix = "") ⇒ String
43 44 45 46 47 48 49 50 |
# File 'lib/relaton_bib/validity.rb', line 43 def to_asciibib(prefix = "") pref = prefix.empty? ? "validity." : "#{prefix}.validity." out = "" out += "#{pref}begins:: #{begins.strftime(FORMAT)}\n" if begins out += "#{pref}ends:: #{ends.strftime(FORMAT)}\n" if ends out += "#{pref}revision:: #{revision.strftime(FORMAT)}\n" if revision out end |
#to_hash ⇒ Hash
33 34 35 36 37 38 39 |
# File 'lib/relaton_bib/validity.rb', line 33 def to_hash hash = {} hash["begins"] = begins.strftime(FORMAT) if begins hash["ends"] = ends.strftime(FORMAT) if ends hash["revision"] = revision.strftime(FORMAT) if revision hash end |
#to_xml(builder) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/relaton_bib/validity.rb', line 24 def to_xml(builder) builder.validity do builder.validityBegins begins.strftime(FORMAT) if begins builder.validityEnds ends.strftime(FORMAT) if ends builder.revision revision.strftime(FORMAT) if revision end end |