module BarcodeValidation

Constants

VERSION

Public Class Methods

scan(input) click to toggle source
# File lib/barcodevalidation.rb, line 13
def scan(input)
  GTIN.new(sanitize(input))
end
scan!(input) click to toggle source
# File lib/barcodevalidation.rb, line 17
def scan!(input)
  scan(input).tap do |result|
    raise InvalidGTINError, input unless result.valid?
  end
end

Private Class Methods

sanitize(input) click to toggle source

Strips punctuation

# File lib/barcodevalidation.rb, line 26
def sanitize(input)
  return input.gsub(/(\s|[-_])/, "") if input.respond_to? :gsub

  input
end