Class: GoogleMaps::Geocoder::Result
- Inherits:
-
Object
- Object
- GoogleMaps::Geocoder::Result
- Includes:
- Enumerable
- Defined in:
- lib/google_maps/geocoder/result.rb
Constant Summary collapse
- STATUS_CODES =
[ "OK", "ZERO_RESULTS", "OVER_QUERY_LIMIT", "REQUEST_DENIED", "INVALID_REQUEST" ]
Instance Attribute Summary collapse
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #all ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(json = {}) ⇒ Result
constructor
A new instance of Result.
- #last ⇒ Object
Constructor Details
#initialize(json = {}) ⇒ Result
Returns a new instance of Result.
10 11 12 13 |
# File 'lib/google_maps/geocoder/result.rb', line 10 def initialize(json = {}) self.status = ActiveSupport::StringInquirer.new(json['status'].downcase) @locations = (json['results'] || []).map { |result| Location.new(result) } end |
Instance Attribute Details
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/google_maps/geocoder/result.rb', line 6 def status @status end |
Instance Method Details
#[](index) ⇒ Object
23 24 25 |
# File 'lib/google_maps/geocoder/result.rb', line 23 def [](index) all[index] end |
#all ⇒ Object
15 16 17 |
# File 'lib/google_maps/geocoder/result.rb', line 15 def all @locations end |
#each(&block) ⇒ Object
19 20 21 |
# File 'lib/google_maps/geocoder/result.rb', line 19 def each(&block) all.each &block end |
#last ⇒ Object
27 28 29 |
# File 'lib/google_maps/geocoder/result.rb', line 27 def last all.last end |