Class: BerkeleyLibrary::Alma::BibNumber

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.

Parameters:

  • bib_number (String)

    The bib number, with or without check digit

Raises:

  • (ArgumentError)

    if the specified string is not an 8- or 9-digit bib number, or if a 9-digit bib number has an incorrect check digit



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_strString (readonly)

Returns the check digit of the bib number, as a string.

Returns:

  • (String)

    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_strString (readonly)

Returns the numeric part of the bib number, excluding check digit, as a string.

Returns:

  • (String)

    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_bibString

Returns the full bib number, including the correct check digit, as a string.

Returns:

  • (String)

    the bib number, 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_valueString

Returns the SRU query value for this MMS ID.

Note that currently only UC Berkeley bib numbers (encoded UCB-bXXXXXXXXX) are supported.

Returns:

  • (String)

    the SRU query value



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_sString

Returns the full bib number, including the correct check digit, as a string.

Returns:

  • (String)

    the bib number, as a string



44
45
46
# File 'lib/berkeley_library/alma/bib_number.rb', line 44

def to_s
  full_bib
end