class RelatonBipm::CommentPeriond

Attributes

from[R]

@return [Date]

to[R]

@return [Date, NilClass]

Public Class Methods

new(from:, to: nil) click to toggle source

@param from [String] date @parma to [String, NilClass] date

# File lib/relaton_bipm/comment_periond.rb, line 11
def initialize(from:, to: nil)
  @from = Date.parse from
  @to = Date.parse to if to
end

Public Instance Methods

to_asciibib(prefix) click to toggle source

@param prefix [String] @return [String]

# File lib/relaton_bipm/comment_periond.rb, line 33
def to_asciibib(prefix)
  pref = prefix.empty? ? prefix : "#{prefix}."
  pref += "commentperiod"
  out = "#{pref}.from:: #{from}\n"
  out += "#{pref}.to:: #{to}\n" if to
  out
end
to_hash() click to toggle source

@return [Hash]

# File lib/relaton_bipm/comment_periond.rb, line 25
def to_hash
  hash = { "from" => from.to_s }
  hash["to"] = to.to_s if to
  hash
end
to_xml(builder) click to toggle source

@param builder [Nokogiri::XML::builder]

# File lib/relaton_bipm/comment_periond.rb, line 17
def to_xml(builder)
  builder.send "comment-period" do
    builder.from from.to_s
    builder.to to.to_s if to
  end
end