Class: IsoBibItem::IsoDocumentId
- Inherits:
-
Object
- Object
- IsoBibItem::IsoDocumentId
- Defined in:
- lib/iso_bib_item/iso_bibliographic_item.rb
Overview
Iso document id.
Instance Attribute Summary collapse
- #id ⇒ String readonly
- #part_number ⇒ Integer readonly
- #prefix ⇒ Prefix readonly
- #project_number ⇒ Integer readonly
- #tc_document_number ⇒ Integer readonly
- #type ⇒ Prefix readonly
Instance Method Summary collapse
- #all_parts ⇒ Object
-
#initialize(project_number:, part_number:, prefix:, id:, type: nil) ⇒ IsoDocumentId
constructor
A new instance of IsoDocumentId.
- #remove_date ⇒ Object
-
#remove_part ⇒ Object
in docid manipulations, assume ISO as the default: id-part:year.
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(project_number:, part_number:, prefix:, id:, type: nil) ⇒ IsoDocumentId
Returns a new instance of IsoDocumentId.
43 44 45 46 47 48 49 |
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 43 def initialize(project_number:, part_number:, prefix:, id:, type: nil) @project_number = project_number @part_number = part_number @prefix = prefix @type = type @id = id end |
Instance Attribute Details
#id ⇒ String (readonly)
33 34 35 |
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 33 def id @id end |
#part_number ⇒ Integer (readonly)
30 31 32 |
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 30 def part_number @part_number end |
#prefix ⇒ Prefix (readonly)
36 37 38 |
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 36 def prefix @prefix end |
#project_number ⇒ Integer (readonly)
27 28 29 |
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 27 def project_number @project_number end |
#tc_document_number ⇒ Integer (readonly)
24 25 26 |
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 24 def tc_document_number @tc_document_number end |
#type ⇒ Prefix (readonly)
39 40 41 |
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 39 def type @type end |
Instance Method Details
#all_parts ⇒ Object
69 70 71 |
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 69 def all_parts @id = @id + " (all parts)" end |
#remove_date ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 61 def remove_date case @type when "Chinese Standard" then @id = @id.sub(/-[12]\d\d\d/, "") else @id = @id.sub(/:[12]\d\d\d/, "") end end |
#remove_part ⇒ Object
in docid manipulations, assume ISO as the default: id-part:year
52 53 54 55 56 57 58 59 |
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 52 def remove_part @part_number = nil case @type when "Chinese Standard" then @id = @id.sub(/\.\d+/, "") else @id = @id.sub(/-\d+/, "") end end |
#to_xml(builder) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 73 def to_xml(builder) attrs = {} attrs[:type] = @type if @type # builder.docidentifier project_number + '-' + part_number, **attrs builder.docidentifier id, **attrs end |