Sha256: 25bc6689e9c70eb6da6812eb3e603d2addf7489adfedf2342e6ae2ffb47af0e8
Contents?: true
Size: 1.07 KB
Versions: 21
Compression:
Stored size: 1.07 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) element = builder.docidentifier id element[:type] = type if type end # @return [Hash] def to_hash hash = { "id" => id } hash["type"] = type if type hash end end end
Version data entries
21 entries across 21 versions & 2 rubygems