Class: BerkeleyLibrary::Alma::MMSID
- Inherits:
-
Object
- Object
- BerkeleyLibrary::Alma::MMSID
- 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
-
#institution ⇒ String
readonly
The four-digit institution code.
-
#mms_id ⇒ String
readonly
The MMS ID, as a string.
-
#type_prefix ⇒ String
readonly
The type prefix part of the MMS ID.
-
#unique_part ⇒ String
readonly
The unique part of the record number.
Instance Method Summary collapse
-
#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.
-
#initialize(id) ⇒ MMSID
constructor
Initializes a new MMSID from a string.
-
#permalink_uri ⇒ URI
Returns the permalink URI for this MMS ID.
-
#sru_query_value ⇒ String
Returns the SRU query value for this MMS ID.
-
#to_s ⇒ String
Returns the MMS ID as a string.
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.
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
#institution ⇒ String (readonly)
Returns the four-digit institution code.
38 39 40 |
# File 'lib/berkeley_library/alma/mms_id.rb', line 38 def institution @institution end |
#mms_id ⇒ String (readonly)
Returns 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_prefix ⇒ String (readonly)
Returns 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_part ⇒ String (readonly)
Returns 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.
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 |
#permalink_uri ⇒ URI
Returns the permalink URI for this MMS ID. Requires Config.alma_permalink_base_uri to be set.
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_value ⇒ String
Returns the SRU query value for this MMS ID.
72 73 74 |
# File 'lib/berkeley_library/alma/mms_id.rb', line 72 def sru_query_value "alma.mms_id=#{mms_id}" end |
#to_s ⇒ String
Returns the MMS ID as a string.
57 58 59 |
# File 'lib/berkeley_library/alma/mms_id.rb', line 57 def to_s mms_id end |