Class: GoogleMaps::Geocoder::Result

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#statusObject

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

#allObject



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

#lastObject



27
28
29
# File 'lib/google_maps/geocoder/result.rb', line 27

def last
  all.last
end