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(project_number:, part_number:, prefix:, id:, type: nil) ⇒ IsoDocumentId

Returns a new instance of IsoDocumentId.

Parameters:

  • project_number (Integer)
  • part_number (Integer)


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

#idString (readonly)

Returns:

  • (String)


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

def id
  @id
end

#part_numberInteger (readonly)

Returns:

  • (Integer)


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

def part_number
  @part_number
end

#prefixPrefix (readonly)

Returns:

  • (Prefix)


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

def prefix
  @prefix
end

#project_numberInteger (readonly)

Returns:

  • (Integer)


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

def project_number
  @project_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

#typePrefix (readonly)

Returns:

  • (Prefix)


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

def type
  @type
end

Instance Method Details

#all_partsObject



69
70
71
# File 'lib/iso_bib_item/iso_bibliographic_item.rb', line 69

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

#remove_dateObject



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_partObject

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