Sha256: a4234c4cef9dff5f965952718beea67ae85b3ee5831d9b43085b52be60a34d1a

Contents?: true

Size: 905 Bytes

Versions: 35

Compression:

Stored size: 905 Bytes

Contents

module RelatonBipm
  class CommentPeriond
    # @return [Date]
    attr_reader :from

    # @return [Date, NilClass]
    attr_reader :to

    # @param from [String] date
    # @parma to [String, NilClass] date
    def initialize(from:, to: nil)
      @from = Date.parse from
      @to = Date.parse to if to
    end

    # @param builder [Nokogiri::XML::builder]
    def to_xml(builder)
      builder.send "comment-period" do
        builder.from from.to_s
        builder.to to.to_s if to
      end
    end

    # @return [Hash]
    def to_hash
      hash = { "from" => from.to_s }
      hash["to"] = to.to_s if to
      hash
    end

    # @param prefix [String]
    # @return [String]
    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
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
relaton-bipm-1.14.1 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.14.0 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.12 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.11 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.10 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.9 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.8 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.7 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.6 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.5 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.4 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.3 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.2 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.1 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.13.0 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.12.3 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.12.2 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.12.1 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.12.0 lib/relaton_bipm/comment_periond.rb
relaton-bipm-1.11.9 lib/relaton_bipm/comment_periond.rb