Sha256: e5db941f3b49b3369613e93027eef2f44e54a566d652da584b2b20397addd86f
Contents?: true
Size: 436 Bytes
Versions: 11
Compression:
Stored size: 436 Bytes
Contents
module PagarMe class Zipcode < PagarMeObject ZIPCODE_REGEXP = /\d{5}[-\.\_\s]?\d{3}/ def self.find(zipcode) raise PagarMe::RequestError.new('invalid zipcode') unless valid_zipcode?(zipcode) sanitized_zipcode = zipcode.gsub(/[-\.\_\s]/, '') self.new PagarMe::Request.get("/zipcodes/#{sanitized_zipcode}").run end def self.valid_zipcode?(zipcode) zipcode.match ZIPCODE_REGEXP end end end
Version data entries
11 entries across 11 versions & 1 rubygems