Sha256: 96698cee38901c9c0377f3c215d0502ce69d68280ba582302f1f66aad44c9c1e
Contents?: true
Size: 1004 Bytes
Versions: 4
Compression:
Stored size: 1004 Bytes
Contents
module BerkeleyLibrary module Location module WorldCat module Symbols 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 class << self include Symbols end def valid?(sym) ALL.include?(sym) end 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 private def array_like?(a) %i[reject empty?].all? { |m| a.respond_to?(m) } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems