Module: BerkeleyLibrary::Location::OCLCNumber

Defined in:
lib/berkeley_library/location/oclc_number.rb

Class Method Summary collapse

Class Method Details

.ensure_oclc_number!(oclc_number) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
# File 'lib/berkeley_library/location/oclc_number.rb', line 5

def ensure_oclc_number!(oclc_number)
  raise ArgumentError, 'OCLC number cannot be nil' if oclc_number.nil?
  raise ArgumentError, "OCLC number #{oclc_number.inspect} is not a string" unless oclc_number.is_a?(String)
  raise ArgumentError, 'OCLC number cannot be empty' if oclc_number == ''
  raise ArgumentError, "OCLC number #{oclc_number.inspect} must not be blank" if oclc_number.strip == ''

  oclc_number
end

.ensure_oclc_numbers!(oclc_numbers) ⇒ Object



14
15
16
17
18
# File 'lib/berkeley_library/location/oclc_number.rb', line 14

def ensure_oclc_numbers!(oclc_numbers)
  oclc_numbers.tap do |numbers|
    numbers.each { |num| ensure_oclc_number!(num) }
  end
end