Class: IsoBibItem::IsoDocumentId

Inherits:
Object
  • Object
show all
Defined in:
lib/iso_bib_item/iso_bibliographic_item.rb

Overview

Iso document id.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ IsoDocumentId

Returns a new instance of IsoDocumentId.

Parameters:

  • project_number (String)
  • part_number (String)
  • subpart_number (String)
  • prefix (String)
  • id (String)
  • type (String)


50
51
52
53
54
55
56
57
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 50

def initialize(**args)
  @project_number = args[:project_number]
  @part_number    = args[:part_number]
  @subpart_number = args[:subpart_number]
  @prefix         = args[:prefix]
  @type           = args[:type]
  @id             = args[:id]
end

Instance Attribute Details

#idString (readonly)

Returns:

  • (String)


36
37
38
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 36

def id
  @id
end

#part_numberString (readonly)

Returns:

  • (String)


30
31
32
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 30

def part_number
  @part_number
end

#prefixString (readonly)

Returns:

  • (String)


39
40
41
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 39

def prefix
  @prefix
end

#project_numberString (readonly)

Returns:

  • (String)


27
28
29
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 27

def project_number
  @project_number
end

#subpart_numberString (readonly)

Returns:

  • (String)


33
34
35
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 33

def subpart_number
  @subpart_number
end

#tc_document_numberInteger (readonly)

Returns:

  • (Integer)


24
25
26
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 24

def tc_document_number
  @tc_document_number
end

#typeString (readonly)

Returns:

  • (String)


42
43
44
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 42

def type
  @type
end

Instance Method Details

#all_partsObject



78
79
80
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 78

def all_parts
  @id = @id + " (all parts)"
end

#remove_dateObject



70
71
72
73
74
75
76
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 70

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_partObject

in docid manipulations, assume ISO as the default: id-part:year



60
61
62
63
64
65
66
67
68
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 60

def remove_part
  @part_number = nil
  @subpart_number = nil
  case @type
  when "Chinese Standard" then @id = @id.sub(/\.\d+/, "")
  else 
    @id = @id.sub(/-\d+/, "")
  end
end

#to_xml(builder) ⇒ Object



82
83
84
85
86
87
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 82

def to_xml(builder)
  attrs = {}
  attrs[:type] = @type if @type
  # builder.docidentifier project_number + '-' + part_number, **attrs
  builder.docidentifier id, **attrs
end