Sha256: 61fe820350499b25a7a90114f52c3ac390e0be96272f92bf96938f62048660eb
Contents?: true
Size: 1016 Bytes
Versions: 3
Compression:
Stored size: 1016 Bytes
Contents
# Identify if tracking numbers are valid, and which service they belong to # Information on validating tracking numbers found here: # http://answers.google.com/answers/threadview/id/207899.html require 'tracking_number/base' require 'tracking_number/usps' require 'tracking_number/fedex' require 'tracking_number/ups' require 'tracking_number/dhl' require 'tracking_number/ontrac' if defined?(ActiveModel::EachValidator) require 'tracking_number/active_model_validator' end module TrackingNumber TYPES = [UPS, UPSTest, FedExExpress, FedExSmartPost, FedExGround, FedExGround18, FedExGround96, USPS91, USPS20, USPS13, USPSTest, DHLExpress, DHLExpressAir, OnTrac] def self.search(body) TYPES.collect { |type| type.search(body) }.flatten end def self.detect(tracking_number) tn = nil for test_klass in (TYPES+[Unknown]) tn = test_klass.new(tracking_number) break if tn.valid? end return tn end def self.new(tracking_number) self.detect(tracking_number) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tracking_number-0.10.5 | lib/tracking_number.rb |
tracking_number-0.10.4 | lib/tracking_number.rb |
tracking_number-0.10.3 | lib/tracking_number.rb |