Class: BerkeleyLibrary::Alma::BibNumber
- Inherits:
-
Object
- Object
- BerkeleyLibrary::Alma::BibNumber
- Includes:
- RecordId
- Defined in:
- lib/berkeley_library/alma/bib_number.rb
Overview
RecordId subclass representing a Millennium bib number.
Constant Summary
Constants included from Constants
Constants::ALMA_RECORD_RE, Constants::DEFAULT_USER_AGENT, Constants::MILLENNIUM_RECORD_RE
Instance Attribute Summary collapse
-
#check_str ⇒ String
readonly
The check digit of the bib number, as a string.
-
#digit_str ⇒ String
readonly
The numeric part of the bib number, excluding check digit, as a string.
Instance Method Summary collapse
-
#full_bib ⇒ String
Returns the full bib number, including the correct check digit, as a string.
-
#initialize(bib_number) ⇒ BibNumber
constructor
Initializes a new BibNumber from the specified string.
-
#sru_query_value ⇒ String
Returns the SRU query value for this MMS ID.
-
#to_s ⇒ String
Returns the full bib number, including the correct check digit, as a string.
Methods included from RecordId
#<=>, #get_marc_record, #get_marc_xml, #marc_uri, parse
Constructor Details
#initialize(bib_number) ⇒ BibNumber
Initializes a new BerkeleyLibrary::Alma::BibNumber from the specified string. Note that a bib number may start with an upper-case B, but it will be converted to lower case.
27 28 29 |
# File 'lib/berkeley_library/alma/bib_number.rb', line 27 def initialize(bib_number) @digit_str, @check_str = split_bib(bib_number) end |
Instance Attribute Details
#check_str ⇒ String (readonly)
Returns the check digit of the bib number, as a string.
16 17 18 |
# File 'lib/berkeley_library/alma/bib_number.rb', line 16 def check_str @check_str end |
#digit_str ⇒ String (readonly)
Returns the numeric part of the bib number, excluding check digit, as a string.
13 14 15 |
# File 'lib/berkeley_library/alma/bib_number.rb', line 13 def digit_str @digit_str end |
Instance Method Details
#full_bib ⇒ String
Returns the full bib number, including the correct check digit, as a string.
37 38 39 |
# File 'lib/berkeley_library/alma/bib_number.rb', line 37 def full_bib "b#{digit_str}#{check_str}" end |
#sru_query_value ⇒ String
Returns the SRU query value for this MMS ID.
Note that currently only UC Berkeley bib numbers (encoded UCB-bXXXXXXXXX
)
are supported.
54 55 56 |
# File 'lib/berkeley_library/alma/bib_number.rb', line 54 def sru_query_value "alma.local_field_996=#{full_bib}" end |
#to_s ⇒ String
Returns the full bib number, including the correct check digit, as a string.
44 45 46 |
# File 'lib/berkeley_library/alma/bib_number.rb', line 44 def to_s full_bib end |