Class: RelatonBipm::CommentPeriond

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_bipm/comment_periond.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, to: nil) ⇒ CommentPeriond

Returns a new instance of CommentPeriond.

Parameters:

  • from (String)

    date



11
12
13
14
# 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

Instance Attribute Details

#fromDate (readonly)

Returns:

  • (Date)


4
5
6
# File 'lib/relaton_bipm/comment_periond.rb', line 4

def from
  @from
end

#toDate, NilClass (readonly)

Returns:

  • (Date, NilClass)


7
8
9
# File 'lib/relaton_bipm/comment_periond.rb', line 7

def to
  @to
end

Instance Method Details

#to_asciibib(prefix) ⇒ String

Parameters:

  • prefix (String)

Returns:

  • (String)


33
34
35
36
37
38
39
# 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_hashHash

Returns:

  • (Hash)


25
26
27
28
29
# 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) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::builder)


17
18
19
20
21
22
# 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