class BerkeleyLibrary::Alma::BarCode

{RecordId} subclass representing an item barcode.

Attributes

barcode[R]

Public Class Methods

new(barcode) click to toggle source

Initialize a barcode. Since we purchase barcodes of varied formats and accept vendor barcodes as well we are only validating whether it’s a string or not.

# File lib/berkeley_library/alma/barcode.rb, line 13
def initialize(barcode)
  string?(barcode)
  @barcode = barcode
end

Public Instance Methods

sru_query_value() click to toggle source

Returns the SRU query value for this Barcode.

@return [String] the Barcode query value

# File lib/berkeley_library/alma/barcode.rb, line 21
def sru_query_value
  "alma.barcode=#{@barcode}"
end

Private Instance Methods

string?(barcode) click to toggle source
# File lib/berkeley_library/alma/barcode.rb, line 27
def string?(barcode)
  raise ArgumentError, "Barcode must be a string: #{barcode.inspect}" unless barcode.is_a?(String)
end