Class: SmartyStreets::USZipcode::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/smartystreets_ruby_sdk/us_zipcode/result.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Result

Returns a new instance of Result.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/smartystreets_ruby_sdk/us_zipcode/result.rb', line 10

def initialize(obj)
  @status = obj['status']
  @reason = obj['reason']
  @input_id = obj['input_id']
  @input_index = obj['input_index']
  @cities = obj.fetch('city_states', [])
  @zipcodes = obj.fetch('zipcodes', [])

  @cities = convert_cities
  @zipcodes = convert_zipcodes
end

Instance Attribute Details

#citiesObject (readonly)

Returns the value of attribute cities.



8
9
10
# File 'lib/smartystreets_ruby_sdk/us_zipcode/result.rb', line 8

def cities
  @cities
end

#input_idObject (readonly)

Returns the value of attribute input_id.



8
9
10
# File 'lib/smartystreets_ruby_sdk/us_zipcode/result.rb', line 8

def input_id
  @input_id
end

#input_indexObject (readonly)

Returns the value of attribute input_index.



8
9
10
# File 'lib/smartystreets_ruby_sdk/us_zipcode/result.rb', line 8

def input_index
  @input_index
end

#reasonObject (readonly)

Returns the value of attribute reason.



8
9
10
# File 'lib/smartystreets_ruby_sdk/us_zipcode/result.rb', line 8

def reason
  @reason
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/smartystreets_ruby_sdk/us_zipcode/result.rb', line 8

def status
  @status
end

#zipcodesObject (readonly)

Returns the value of attribute zipcodes.



8
9
10
# File 'lib/smartystreets_ruby_sdk/us_zipcode/result.rb', line 8

def zipcodes
  @zipcodes
end

Instance Method Details

#convert_citiesObject



26
27
28
29
30
31
32
33
34
# File 'lib/smartystreets_ruby_sdk/us_zipcode/result.rb', line 26

def convert_cities
  converted_cities = []

  @cities.each do |city|
    converted_cities.push(City.new(city))
  end

  converted_cities
end

#convert_zipcodesObject



36
37
38
39
40
41
42
43
44
# File 'lib/smartystreets_ruby_sdk/us_zipcode/result.rb', line 36

def convert_zipcodes
  converted_zipcodes = []

  @zipcodes.each do |zipcode|
    converted_zipcodes.push(ZipCode.new(zipcode))
  end

  converted_zipcodes
end

#valid?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/smartystreets_ruby_sdk/us_zipcode/result.rb', line 22

def valid?
  @status.nil? and @reason.nil?
end