Sha256: 59d314376b4146b0358d6ef21b5650b6efa22d5d92064e0db005ddda2c3a133b
Contents?: true
Size: 1 KB
Versions: 24
Compression:
Stored size: 1 KB
Contents
require_relative 'city' require_relative 'zip_code' module SmartyStreets module USZipcode # See "https://smartystreets.com/docs/cloud/us-zipcode-api#root" class Result attr_reader :reason, :input_index, :cities, :zipcodes, :status def initialize(obj) @status = obj['status'] @reason = obj['reason'] @input_index = obj['input_index'] @cities = obj.fetch('city_states', []) @zipcodes = obj.fetch('zipcodes', []) @cities = convert_cities @zipcodes = convert_zipcodes end def valid? @status.nil? and @reason.nil? end def convert_cities converted_cities = [] @cities.each do |city| converted_cities.push(City.new(city)) end converted_cities end def convert_zipcodes converted_zipcodes = [] @zipcodes.each do |zipcode| converted_zipcodes.push(ZipCode.new(zipcode)) end converted_zipcodes end end end end
Version data entries
24 entries across 24 versions & 1 rubygems