Sha256: da8bd356e4bffd9940448227806d0fd19e664486f820bbcd5763e4c71cc572a6
Contents?: true
Size: 1.4 KB
Versions: 42
Compression:
Stored size: 1.4 KB
Contents
module RelatonBib class Validity FORMAT = "%Y-%m-%d %H:%M".freeze # @return [Time, NilClass] attr_reader :begins # @return [Time, NilClass] attr_reader :ends # @return [Time, NilClass] attr_reader :revision # @param begins [Time, NilClass] # @param ends [Time, NilClass] # @param revision [Time, NilClass] def initialize(begins: nil, ends: nil, revision: nil) @begins = begins @ends = ends @revision = revision end # @param [Nokogiri::XML::Builder] 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 # @return [Hash] 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 # @param prefix [String] # @return [String] 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 end end
Version data entries
42 entries across 42 versions & 1 rubygems