class BerkeleyLibrary::Alma::MMSID

{RecordId} subclass representing an Alma MMS ID. Note that only bibliographic records (prefix ‘99`) are supported.

See [Record Numbers](knowledge.exlibrisgroup.com/Alma/Product_Documentation/010Alma_Online_Help_(English)/Metadata_Management/005Introduction_to_Metadata_Management/020Record_Numbers) in the Alma documentation.

Constants

INST_CODE_UCB

The four-digit institition code for UC berkeley

UNIQ_PREFIX_UCB

The UC Berkeley prefix to the unique part of the MMS ID

Attributes

institution[R]

@return [String] the four-digit institution code

mms_id[R]

@return [String] the MMS ID, as a string

type_prefix[R]

@return [String] the type prefix part of the MMS ID. Note that only bibliographic records

(prefix `99`) are supported.
unique_part[R]

@return [String] the unique part of the record number

Public Class Methods

new(id) click to toggle source

Initializes a new {MMSID} from a string.

@param id [String] the ID string @raise [ArgumentError] if the specified string is not an Alma bibliographic MMS ID.

# File lib/berkeley_library/alma/mms_id.rb, line 47
def initialize(id)
  @mms_id, @type_prefix, @unique_part, @institution = parse_mms_id(id)
end

Public Instance Methods

berkeley?() click to toggle source

Whether this ID appears to be for a Berkeley record, based on its institution code and on whether the unique part of the ID starts with the expected prefix for Berkeley.

@return [TrueClass, FalseClass] true if this ID appears to be for a Berkeley record, false otherwise

# File lib/berkeley_library/alma/mms_id.rb, line 80
def berkeley?
  unique_part.start_with?(UNIQ_PREFIX_UCB) && institution == INST_CODE_UCB
end
sru_query_value() click to toggle source

Returns the SRU query value for this MMS ID.

@return [String] the SRU query value

# File lib/berkeley_library/alma/mms_id.rb, line 72
def sru_query_value
  "alma.mms_id=#{mms_id}"
end
to_s() click to toggle source

Returns the MMS ID as a string.

@return [String] the MMS ID

# File lib/berkeley_library/alma/mms_id.rb, line 57
def to_s
  mms_id
end

Private Instance Methods

parse_mms_id(id) click to toggle source
# File lib/berkeley_library/alma/mms_id.rb, line 93
def parse_mms_id(id)
  raise ArgumentError, "Not an MMS ID: #{id.inspect}" unless (md = ALMA_RECORD_RE.match(id.to_s))

  md.to_a
end