Class: RelatonBipm::StructuredIdentifier
- Inherits:
-
Object
- Object
- RelatonBipm::StructuredIdentifier
- Defined in:
- lib/relaton_bipm/structured_identifier.rb
Instance Attribute Summary collapse
- #appendix ⇒ String? readonly
- #docnumber ⇒ String readonly
- #part ⇒ String? readonly
Instance Method Summary collapse
-
#initialize(docnumber:, part: nil, appendix: nil) ⇒ StructuredIdentifier
constructor
A new instance of StructuredIdentifier.
- #presence? ⇒ true
- #to_asciibib(prefix = "") ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(docnumber:, part: nil, appendix: nil) ⇒ StructuredIdentifier
Returns a new instance of StructuredIdentifier.
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
#appendix ⇒ String? (readonly)
7 8 9 |
# File 'lib/relaton_bipm/structured_identifier.rb', line 7 def appendix @appendix end |
#docnumber ⇒ String (readonly)
4 5 6 |
# File 'lib/relaton_bipm/structured_identifier.rb', line 4 def docnumber @docnumber end |
#part ⇒ String? (readonly)
7 8 9 |
# File 'lib/relaton_bipm/structured_identifier.rb', line 7 def part @part end |
Instance Method Details
#presence? ⇒ true
47 48 49 |
# File 'lib/relaton_bipm/structured_identifier.rb', line 47 def presence? true end |
#to_asciibib(prefix = "") ⇒ 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_hash ⇒ 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
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 |