Sha256: 627dd0ae116451919ae380b8855f722f59a1646e465aec88e8346843ad8f33f5
Contents?: true
Size: 1.04 KB
Versions: 12
Compression:
Stored size: 1.04 KB
Contents
module RelatonBib # Document identifier. class DocumentIdentifier # @return [String] attr_reader :id # @return [String, NilClass] attr_reader :type # @param id [String] # @param type [String, NilClass] def initialize(id:, type: nil) @id = id @type = type end # in docid manipulations, assume ISO as the default: id-part:year def remove_part case @type when "Chinese Standard" then @id.sub!(/\.\d+/, "") else @id.sub!(/-\d+/, "") end end def remove_date case @type when "Chinese Standard" then @id.sub!(/-[12]\d\d\d/, "") else @id.sub!(/:[12]\d\d\d/, "") end end def all_parts @id += " (all parts)" end # # Add docidentifier xml element # # @param [Nokogiri::XML::Builder] builder # def to_xml(builder) builder.docidentifier(id, type: type) end # @return [Hash] def to_hash hash = { "id" => id } hash["type"] = type if type hash end end end
Version data entries
12 entries across 12 versions & 1 rubygems