Sha256: abde8afa9618be97871da970fc07980237604d056e3e1ded426064e7a9efd4fe
Contents?: true
Size: 885 Bytes
Versions: 5
Compression:
Stored size: 885 Bytes
Contents
module TrackingNumber class DHL < Base def carrier :dhl end def valid_checksum? # standard mod 7 check sequence, check_digit = matches return true if sequence.to_i % 7 == check_digit.to_i end end #DHL Air (a division of DHL Express) have 11 digit numbers class DHLExpressAir < DHL SEARCH_PATTERN = /(\b([0-9]\s*){11,11}\b)/ VERIFY_PATTERN = /^([0-9]{10,10})([0-9])$/ def matches self.tracking_number.scan(VERIFY_PATTERN).flatten end end #DHL Express numbers are 10 digits long # http://www.dhl.co.uk/content/dam/downloads/uk/Express/PDFs/developer_centre/dhlis9_shipment_and_piece_ranges_v1.3.pdf class DHLExpress < DHL SEARCH_PATTERN = /(\b([0-9]\s*){10,10}\b)/ VERIFY_PATTERN = /^([0-9]{9,9})([0-9])$/ def matches self.tracking_number.scan(VERIFY_PATTERN).flatten end end end
Version data entries
5 entries across 5 versions & 1 rubygems