Class: SmartyStreets::USZipcode::Result
- Inherits:
-
Object
- Object
- SmartyStreets::USZipcode::Result
- Defined in:
- lib/smartystreets_ruby_sdk/us_zipcode/result.rb
Overview
Instance Attribute Summary collapse
-
#cities ⇒ Object
readonly
Returns the value of attribute cities.
-
#input_id ⇒ Object
readonly
Returns the value of attribute input_id.
-
#input_index ⇒ Object
readonly
Returns the value of attribute input_index.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#zipcodes ⇒ Object
readonly
Returns the value of attribute zipcodes.
Instance Method Summary collapse
- #convert_cities ⇒ Object
- #convert_zipcodes ⇒ Object
-
#initialize(obj) ⇒ Result
constructor
A new instance of Result.
- #valid? ⇒ Boolean
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
#cities ⇒ Object (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_id ⇒ Object (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_index ⇒ Object (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 |
#reason ⇒ Object (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 |
#status ⇒ Object (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 |
#zipcodes ⇒ Object (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_cities ⇒ Object
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_zipcodes ⇒ Object
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
22 23 24 |
# File 'lib/smartystreets_ruby_sdk/us_zipcode/result.rb', line 22 def valid? @status.nil? and @reason.nil? end |