Class: RelatonIsoBib::StructuredIdentifier
- Inherits:
-
Object
- Object
- RelatonIsoBib::StructuredIdentifier
- Defined in:
- lib/relaton_iso_bib/structured_identifier.rb
Overview
Document structured identifier.
Instance Attribute Summary collapse
- #part ⇒ Integer, NilClass readonly
- #project_number ⇒ String readonly
- #subpart ⇒ Integer, NilClass readonly
- #tc_document_number ⇒ Integer, NilClass readonly
- #type ⇒ String, NilClass readonly
Instance Method Summary collapse
- #all_parts ⇒ Object
- #id ⇒ Object
-
#initialize(**args) ⇒ StructuredIdentifier
constructor
A new instance of StructuredIdentifier.
- #remove_date ⇒ Object
-
#remove_part ⇒ Object
in docid manipulations, assume ISO as the default: id-part:year.
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(**args) ⇒ StructuredIdentifier
Returns a new instance of StructuredIdentifier.
24 25 26 27 28 29 30 31 |
# File 'lib/relaton_iso_bib/structured_identifier.rb', line 24 def initialize(**args) @tc_document_number = args[:tc_document_number] @project_number = args[:project_number] @part = args[:part] @subpart = args[:subpart] @prefix = args[:prefix] @type = args[:type] end |
Instance Attribute Details
#part ⇒ Integer, NilClass (readonly)
11 12 13 |
# File 'lib/relaton_iso_bib/structured_identifier.rb', line 11 def part @part end |
#project_number ⇒ String (readonly)
8 9 10 |
# File 'lib/relaton_iso_bib/structured_identifier.rb', line 8 def project_number @project_number end |
#subpart ⇒ Integer, NilClass (readonly)
14 15 16 |
# File 'lib/relaton_iso_bib/structured_identifier.rb', line 14 def subpart @subpart end |
#tc_document_number ⇒ Integer, NilClass (readonly)
5 6 7 |
# File 'lib/relaton_iso_bib/structured_identifier.rb', line 5 def tc_document_number @tc_document_number end |
#type ⇒ String, NilClass (readonly)
17 18 19 |
# File 'lib/relaton_iso_bib/structured_identifier.rb', line 17 def type @type end |
Instance Method Details
#all_parts ⇒ Object
52 53 54 |
# File 'lib/relaton_iso_bib/structured_identifier.rb', line 52 def all_parts @project_number = @project_number + " (all parts)" end |
#id ⇒ Object
56 57 58 |
# File 'lib/relaton_iso_bib/structured_identifier.rb', line 56 def id project_number end |
#remove_date ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/relaton_iso_bib/structured_identifier.rb', line 44 def remove_date case @type when "Chinese Standard" then @project_number = @project_number.sub(/-[12]\d\d\d/, "") else @project_number = @project_number.sub(/:[12]\d\d\d/, "") end end |
#remove_part ⇒ Object
in docid manipulations, assume ISO as the default: id-part:year
34 35 36 37 38 39 40 41 42 |
# File 'lib/relaton_iso_bib/structured_identifier.rb', line 34 def remove_part @part_number = nil @subpart_number = nil case @type when "Chinese Standard" then @project_number = @project_number.sub(/\.\d+/, "") else @project_number = @project_number.sub(/-\d+/, "") end end |
#to_xml(builder) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/relaton_iso_bib/structured_identifier.rb', line 61 def to_xml(builder) xml = builder.structuredidentifier do pn = builder.send "project-number", project_number pn[:part] = part if part pn[:subpart] = subpart if subpart builder.send "tc-document-number", tc_document_number if tc_document_number end xml[:type] = type if type end |