Sha256: 46d8859aba2494e3d4132b2ca33925a5f256b38461380a7ce4310ba9762fb3e0

Contents?: true

Size: 479 Bytes

Versions: 1

Compression:

Stored size: 479 Bytes

Contents

module TrackingNumberValidator
  class Service

    VALIDATORS = [
      DHLValidator,
      FedExGroundValidator
    ]

    def self.detect(tracking_number)
      tracking_number = sanitize(tracking_number)
      VALIDATORS.each do |validator|
        validator = validator.new(tracking_number)
        return validator.name if validator.valid?
      end
      nil
    end

    private
    def self.sanitize(tracking_number)
      tracking_number[/\d+/] || ""
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracking_number_validator-0.0.1 lib/tracking_number_validator/service.rb