Sha256: 7a4633b9533a7f7fb5d653ae72032487222fa9a0dc000acc75f3cae59e4cb8c0

Contents?: true

Size: 584 Bytes

Versions: 1

Compression:

Stored size: 584 Bytes

Contents

module Barometer
  #
  # Format: Postal Code
  #
  # eg. H0H 0H0
  #
  # This class is used to determine if a query is a
  # :postalcode and what the country_code is.
  #
  class Query::Format::Postalcode < Query::Format

    def self.format; :postalcode; end
    def self.country_code(query=nil); "CA"; end
    def self.regex
      # Rules: no D, F, I, O, Q, or U anywhere
      # Basic validation: ^[ABCEGHJ-NPRSTVXY]{1}[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}
      #   [ ]?[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[0-9]{1}$
      /^[A-Z]{1}[\d]{1}[A-Z]{1}[ ]?[\d]{1}[A-Z]{1}[\d]{1}$/
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
barometer-0.8.0 lib/barometer/formats/postalcode.rb