class RelatonIsoBib::StructuredIdentifier
Document structured identifier.
Attributes
part[R]
@return [Integer, NilClass]
project_number[R]
@return [String]
subpart[R]
@return [Integer, NilClass]
tc_document_number[R]
@return [Integer, NilClass]
type[R]
@return [String, NilClass]
Public Class Methods
new(**args)
click to toggle source
@param tc_document_number
[Integer, NilClass] @param project_number
[String] @param part [String, NilClass] @param subpart [String, NilClass] @param type [String, NilClass]
# 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] @type = args[:type] end
Public Instance Methods
all_parts()
click to toggle source
# File lib/relaton_iso_bib/structured_identifier.rb, line 52 def all_parts @project_number = @project_number + " (all parts)" end
id()
click to toggle source
# File lib/relaton_iso_bib/structured_identifier.rb, line 56 def id project_number end
presence?()
click to toggle source
# File lib/relaton_iso_bib/structured_identifier.rb, line 102 def presence? true end
remove_date()
click to toggle source
# File lib/relaton_iso_bib/structured_identifier.rb, line 44 def remove_date if @type == "Chinese Standard" @project_number.sub!(/-[12]\d\d\d/, "") else @project_number.sub!(/:[12]\d\d\d/, "") end end
remove_part()
click to toggle source
in docid manipulations, assume ISO as the default: id-part:year
# File lib/relaton_iso_bib/structured_identifier.rb, line 33 def remove_part @part = nil @subpart = nil @project_number = case @type when "Chinese Standard" @project_number.sub(/\.\d+/, "") else @project_number = @project_number.sub(/-\d+/, "") end end
to_asciibib(prefix = "")
click to toggle source
@param prefix [String] @return [String]
# File lib/relaton_iso_bib/structured_identifier.rb, line 86 def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength pref = prefix.empty? ? prefix : prefix + "." pref += "structured_identifier" out = "" if tc_document_number out += "#{pref}.tc_document_number:: #{tc_document_number}\n" end if project_number out += "#{pref}.project_number:: #{project_number}\n" end out += "#{pref}.part:: #{part}\n" if part out += "#{pref}.subpart:: #{subpart}\n" if subpart out += "#{pref}.type:: #{type}\n" if type out end
to_hash()
click to toggle source
@return [Hash]
# File lib/relaton_iso_bib/structured_identifier.rb, line 74 def to_hash hash = {} hash["tc_document_number"] = tc_document_number if tc_document_number hash["project_number"] = project_number if project_number hash["part"] = part if part hash["subpart"] = subpart if subpart hash["type"] = type if type hash end
to_xml(builder)
click to toggle source
@param builder [Nokogiri::XML::Builder]
# 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 if tc_document_number builder.send "tc-document-number", tc_document_number end end xml[:type] = type if type end