Class: RelatonBib::StructuredIdentifier
- Includes:
- RelatonBib
- Defined in:
- lib/relaton_bib/structured_identifier.rb
Constant Summary
Constants included from RelatonBib
Instance Attribute Summary collapse
- #agency ⇒ Array<String> readonly
- #docnumber ⇒ String readonly
- #edition ⇒ String, NilClass readonly
- #klass ⇒ String, NilClass readonly
- #language ⇒ String, NilClass readonly
- #partnumber ⇒ String, NilClass readonly
- #supplementnumber ⇒ String, NilClass readonly
- #supplementtype ⇒ String, NilClass readonly
- #type ⇒ String, NilClass readonly
- #version ⇒ String, NilClass readonly
- #year ⇒ String, NilClass readonly
Instance Method Summary collapse
- #all_parts ⇒ Object
-
#initialize(docnumber:, **args) ⇒ StructuredIdentifier
constructor
A new instance of StructuredIdentifier.
-
#remove_date ⇒ Object
rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
-
#remove_part ⇒ Object
in docid manipulations, assume ISO as the default: id-part:year.
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Methods included from RelatonBib
Constructor Details
#initialize(docnumber:, **args) ⇒ StructuredIdentifier
Returns a new instance of StructuredIdentifier.
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/relaton_bib/structured_identifier.rb', line 72 def initialize(docnumber:, **args) @type = args[:type] @agency = args[:agency] @klass = args[:class] @docnumber = docnumber @partnumber = args[:partnumber] @edition = args[:edition] @version = args[:version] @supplementtype = args[:supplementtype] @supplementnumber = args[:supplementnumber] @language = args[:language] @year = args[:year] end |
Instance Attribute Details
#agency ⇒ Array<String> (readonly)
53 54 55 |
# File 'lib/relaton_bib/structured_identifier.rb', line 53 def agency @agency end |
#docnumber ⇒ String (readonly)
50 51 52 |
# File 'lib/relaton_bib/structured_identifier.rb', line 50 def docnumber @docnumber end |
#edition ⇒ String, NilClass (readonly)
56 57 58 |
# File 'lib/relaton_bib/structured_identifier.rb', line 56 def edition @edition end |
#klass ⇒ String, NilClass (readonly)
56 57 58 |
# File 'lib/relaton_bib/structured_identifier.rb', line 56 def klass @klass end |
#language ⇒ String, NilClass (readonly)
56 57 58 |
# File 'lib/relaton_bib/structured_identifier.rb', line 56 def language @language end |
#partnumber ⇒ String, NilClass (readonly)
56 57 58 |
# File 'lib/relaton_bib/structured_identifier.rb', line 56 def partnumber @partnumber end |
#supplementnumber ⇒ String, NilClass (readonly)
56 57 58 |
# File 'lib/relaton_bib/structured_identifier.rb', line 56 def supplementnumber @supplementnumber end |
#supplementtype ⇒ String, NilClass (readonly)
56 57 58 |
# File 'lib/relaton_bib/structured_identifier.rb', line 56 def supplementtype @supplementtype end |
#type ⇒ String, NilClass (readonly)
56 57 58 |
# File 'lib/relaton_bib/structured_identifier.rb', line 56 def type @type end |
#version ⇒ String, NilClass (readonly)
56 57 58 |
# File 'lib/relaton_bib/structured_identifier.rb', line 56 def version @version end |
#year ⇒ String, NilClass (readonly)
56 57 58 |
# File 'lib/relaton_bib/structured_identifier.rb', line 56 def year @year end |
Instance Method Details
#all_parts ⇒ Object
137 138 139 |
# File 'lib/relaton_bib/structured_identifier.rb', line 137 def all_parts @docnumber = @docnumber + " (all parts)" end |
#remove_date ⇒ Object
rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
122 123 124 125 126 127 128 129 |
# File 'lib/relaton_bib/structured_identifier.rb', line 122 def remove_date if @type == "Chinese Standard" @docnumber.sub!(/-[12]\d\d\d/, "") else @docnumber.sub!(/:[12]\d\d\d/, "") end @year = nil end |
#remove_part ⇒ Object
in docid manipulations, assume ISO as the default: id-part:year
132 133 134 135 |
# File 'lib/relaton_bib/structured_identifier.rb', line 132 def remove_part @partnumber = nil @docnumber = @docnumber.sub(/-\d+/, "") end |
#to_hash ⇒ Hash
106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/relaton_bib/structured_identifier.rb', line 106 def to_hash hash = { "docnumber" => docnumber } hash["type"] = type if type hash["agency"] = single_element_array agency if agency&.any? hash["class"] = klass if klass hash["partnumber"] = partnumber if partnumber hash["edition"] = edition if edition hash["version"] = version if version hash["supplementtype"] = supplementtype if supplementtype hash["supplementnumber"] = supplementnumber if supplementnumber hash["language"] = language if language hash["year"] = year if year hash end |
#to_xml(builder) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/relaton_bib/structured_identifier.rb', line 89 def to_xml(builder) xml = builder.structuredidentifier do |b| agency&.each { |a| b.agency a } b.class_ klass if klass b.docnumber docnumber b.partnumber partnumber if partnumber b.edition edition if edition b.version version if version b.supplementtype supplementtype if supplementtype b.supplementnumber supplementnumber if supplementnumber b.language language if language b.year year if year end xml[:type] = type if type end |