Sha256: 62c4aa08ce504e41131aaa12c302545a0da4a5bc6f3f28295f373ae37ae36b19

Contents?: true

Size: 829 Bytes

Versions: 5

Compression:

Stored size: 829 Bytes

Contents

require 'berkeley_library/alma/record_id'

module BerkeleyLibrary
  module Alma
    # {RecordId} subclass representing an item barcode.
    class BarCode
      include RecordId

      attr_reader :barcode

      # 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.
      def initialize(barcode)
        string?(barcode)
        @barcode = barcode
      end

      # Returns the SRU query value for this Barcode.
      #
      # @return [String] the Barcode query value
      def sru_query_value
        "alma.barcode=#{@barcode}"
      end

      private

      def string?(barcode)
        raise ArgumentError, "Barcode must be a string: #{barcode.inspect}" unless barcode.is_a?(String)
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
berkeley_library-alma-0.0.7.1 lib/berkeley_library/alma/barcode.rb
berkeley_library-alma-0.0.7 lib/berkeley_library/alma/barcode.rb
berkeley_library-alma-0.0.6 lib/berkeley_library/alma/barcode.rb
berkeley_library-alma-0.0.5 lib/berkeley_library/alma/barcode.rb
berkeley_library-alma-0.0.4 lib/berkeley_library/alma/barcode.rb