Class: RelatonBipm::StructuredIdentifier

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(docnumber:, part: nil, appendix: nil) ⇒ StructuredIdentifier

Returns a new instance of StructuredIdentifier.

Parameters:

  • docnumber (String)
  • part (String) (defaults to: nil)
  • appendix (String) (defaults to: nil)


12
13
14
15
16
# File 'lib/relaton_bipm/structured_identifier.rb', line 12

def initialize(docnumber:, part: nil, appendix: nil)
  @docnumber = docnumber
  @part = part
  @appendix = appendix
end

Instance Attribute Details

#appendixString? (readonly)

Returns:

  • (String, nil)


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

def appendix
  @appendix
end

#docnumberString (readonly)

Returns:

  • (String)


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

def docnumber
  @docnumber
end

#partString? (readonly)

Returns:

  • (String, nil)


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

def part
  @part
end

Instance Method Details

#presence?true

Returns:

  • (true)


47
48
49
# File 'lib/relaton_bipm/structured_identifier.rb', line 47

def presence?
  true
end

#to_asciibib(prefix = "") ⇒ String

Parameters:

  • prefix (String) (defaults to: "")

Returns:

  • (String)


37
38
39
40
41
42
43
44
# File 'lib/relaton_bipm/structured_identifier.rb', line 37

def to_asciibib(prefix = "")
  pref = prefix.empty? ? prefix : prefix + "."
  pref += "structuredidentifier"
  out = "#{pref}.docnumber:: #{docnumber}\n"
  out += "#{pref}.part:: #{part}\n" if part
  out += "#{pref}.appendix:: #{appendix}\n" if appendix
  out
end

#to_hashHash

Returns:

  • (Hash)


28
29
30
31
32
33
# File 'lib/relaton_bipm/structured_identifier.rb', line 28

def to_hash
  hash = { "docnumber" => docnumber }
  hash["part"] = part if part
  hash["appendix"] = appendix if appendix
  hash
end

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


19
20
21
22
23
24
25
# File 'lib/relaton_bipm/structured_identifier.rb', line 19

def to_xml(builder)
  builder.structuredidentifier do |b|
    b.docnumber docnumber
    b.part part if part
    b.appendix appendix if appendix
  end
end