Class: RelatonItu::StructuredIdentifier
- Inherits:
-
Object
- Object
- RelatonItu::StructuredIdentifier
- Defined in:
- lib/relaton_itu/structured_identifier.rb
Instance Attribute Summary collapse
- #annexid ⇒ String, NilClass readonly
- #bureau ⇒ String readonly
- #docnumber ⇒ String readonly
Instance Method Summary collapse
-
#initialize(bureau:, docnumber:, annexid: nil) ⇒ StructuredIdentifier
constructor
A new instance of StructuredIdentifier.
- #presence? ⇒ Boolean
- #to_asciibib(prefix) ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(bureau:, docnumber:, annexid: nil) ⇒ StructuredIdentifier
Returns a new instance of StructuredIdentifier.
12 13 14 15 16 17 18 19 |
# File 'lib/relaton_itu/structured_identifier.rb', line 12 def initialize(bureau:, docnumber:, annexid: nil) unless EditorialGroup::BUREAUS.include? bureau Util.warn "Invalid bureau: `#{bureau}`" end @bureau = bureau @docnumber = docnumber @annexid = annexid end |
Instance Attribute Details
#annexid ⇒ String, NilClass (readonly)
7 8 9 |
# File 'lib/relaton_itu/structured_identifier.rb', line 7 def annexid @annexid end |
#bureau ⇒ String (readonly)
4 5 6 |
# File 'lib/relaton_itu/structured_identifier.rb', line 4 def bureau @bureau end |
#docnumber ⇒ String (readonly)
4 5 6 |
# File 'lib/relaton_itu/structured_identifier.rb', line 4 def docnumber @docnumber end |
Instance Method Details
#presence? ⇒ Boolean
47 48 49 |
# File 'lib/relaton_itu/structured_identifier.rb', line 47 def presence? true end |
#to_asciibib(prefix) ⇒ String
39 40 41 42 43 44 45 |
# File 'lib/relaton_itu/structured_identifier.rb', line 39 def to_asciibib(prefix) pref = prefix.empty? ? prefix : prefix + "." pref += "structuredidentifier" out = "#{pref}.bureau:: #{bureau}\n#{pref}.docnumber:: #{docnumber}\n" out += "#{pref}.annexid:: #{annexid}\n" if annexid out end |
#to_hash ⇒ Hash
31 32 33 34 35 |
# File 'lib/relaton_itu/structured_identifier.rb', line 31 def to_hash hash = { bureau: bureau, docnumber: docnumber } hash[:annexid] = annexid if annexid hash end |
#to_xml(builder) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/relaton_itu/structured_identifier.rb', line 22 def to_xml(builder) builder.structuredidentifier do |b| b.bureau bureau b.docnumber docnumber b.annexid annexid if annexid end end |