Module: BerkeleyLibrary::Holdings::WorldCat::Symbols

Extended by:
Symbols
Included in:
Symbols
Defined in:
lib/berkeley_library/holdings/world_cat/symbols.rb

Constant Summary collapse

NRLF =
%w[ZAP ZAPSP].freeze
SRLF =
%w[HH0 ZAS ZASSP].freeze
RLF =
(NRLF + SRLF).freeze
UC =
%w[CLU CRU CUI CUN CUS CUT CUV CUX CUY CUZ MERUC].freeze
ALL =
(RLF + UC).freeze

Instance Method Summary collapse

Instance Method Details

#ensure_valid!(symbols) ⇒ Object

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
27
# File 'lib/berkeley_library/holdings/world_cat/symbols.rb', line 20

def ensure_valid!(symbols)
  raise ArgumentError, "Not a list of institution symbols: #{symbols.inspect}" unless array_like?(symbols)
  raise ArgumentError, 'No institution symbols provided' if symbols.empty?

  return symbols unless (invalid = symbols.reject { |s| Symbols.valid?(s) }).any?

  raise ArgumentError, "Invalid institution symbol(s): #{invalid.map(&:inspect).join(', ')}"
end

#valid?(sym) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/berkeley_library/holdings/world_cat/symbols.rb', line 16

def valid?(sym)
  ALL.include?(sym)
end