Class: BerkeleyLibrary::Alma::MMSID

Inherits:
Object
  • Object
show all
Includes:
RecordId, Util
Defined in:
lib/berkeley_library/alma/mms_id.rb

Overview

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

See Record Numbers in the Alma documentation.

Constant Summary collapse

UNIQ_PREFIX_UCB =

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

'10'.freeze
INST_CODE_UCB =

The four-digit institition code for UC berkeley

'6532'.freeze

Constants included from Constants

Constants::ALMA_RECORD_RE, Constants::DEFAULT_USER_AGENT, Constants::MILLENNIUM_RECORD_RE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RecordId

#<=>, #get_marc_record, #get_marc_xml, #marc_uri, parse

Constructor Details

#initialize(id) ⇒ MMSID

Initializes a new BerkeleyLibrary::Alma::MMSID from a string.

Parameters:

  • id (String)

    the ID string

Raises:

  • (ArgumentError)

    if the specified string is not an Alma bibliographic MMS ID.



47
48
49
# 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

Instance Attribute Details

#institutionString (readonly)

Returns the four-digit institution code.

Returns:

  • (String)

    the four-digit institution code



38
39
40
# File 'lib/berkeley_library/alma/mms_id.rb', line 38

def institution
  @institution
end

#mms_idString (readonly)

Returns the MMS ID, as a string.

Returns:

  • (String)

    the MMS ID, as a string



28
29
30
# File 'lib/berkeley_library/alma/mms_id.rb', line 28

def mms_id
  @mms_id
end

#type_prefixString (readonly)

Returns the type prefix part of the MMS ID. Note that only bibliographic records (prefix 99) are supported.

Returns:

  • (String)

    the type prefix part of the MMS ID. Note that only bibliographic records (prefix 99) are supported.



32
33
34
# File 'lib/berkeley_library/alma/mms_id.rb', line 32

def type_prefix
  @type_prefix
end

#unique_partString (readonly)

Returns the unique part of the record number.

Returns:

  • (String)

    the unique part of the record number



35
36
37
# File 'lib/berkeley_library/alma/mms_id.rb', line 35

def unique_part
  @unique_part
end

Instance Method Details

#berkeley?TrueClass, FalseClass

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.

Returns:

  • (TrueClass, FalseClass)

    true if this ID appears to be for a Berkeley record, false otherwise



80
81
82
# File 'lib/berkeley_library/alma/mms_id.rb', line 80

def berkeley?
  unique_part.start_with?(UNIQ_PREFIX_UCB) && institution == INST_CODE_UCB
end

Returns the permalink URI for this MMS ID. Requires Config.alma_permalink_base_uri to be set.

Returns:

  • (URI)

    the permalink URI.



65
66
67
# File 'lib/berkeley_library/alma/mms_id.rb', line 65

def permalink_uri
  URIs.append(permalink_base_uri, "alma#{mms_id}")
end

#sru_query_valueString

Returns the SRU query value for this MMS ID.

Returns:

  • (String)

    the SRU query value



72
73
74
# File 'lib/berkeley_library/alma/mms_id.rb', line 72

def sru_query_value
  "alma.mms_id=#{mms_id}"
end

#to_sString

Returns the MMS ID as a string.

Returns:

  • (String)

    the MMS ID



57
58
59
# File 'lib/berkeley_library/alma/mms_id.rb', line 57

def to_s
  mms_id
end