Sha256: 9c218d57075ec87711fdfec03dc5a0bf30bc41d7492eee9d9a5c7784d0605089

Contents?: true

Size: 756 Bytes

Versions: 5

Compression:

Stored size: 756 Bytes

Contents

module BerkeleyLibrary
  module Holdings
    module OCLCNumber
      class << self
        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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
berkeley_library-holdings-1.0.5 lib/berkeley_library/holdings/oclc_number.rb
berkeley_library-holdings-1.0.4 lib/berkeley_library/holdings/oclc_number.rb
berkeley_library-holdings-1.0.3 lib/berkeley_library/holdings/oclc_number.rb
berkeley_library-holdings-1.0.2 lib/berkeley_library/holdings/oclc_number.rb
berkeley_library-holdings-1.0.1 lib/berkeley_library/holdings/oclc_number.rb