Sha256: 3ecb94c6e1ca62f4f1e37120aeb2cc1c9cdf8e81dca183fec44dddbf9faf31e5

Contents?: true

Size: 639 Bytes

Versions: 5

Compression:

Stored size: 639 Bytes

Contents

module GoogleMaps
  module Geocoder
    class Result
      include Enumerable

      attr_accessor :status

      STATUS_CODES        = [ "OK", "ZERO_RESULTS", "OVER_QUERY_LIMIT", "REQUEST_DENIED", "INVALID_REQUEST" ]

      def initialize(json = {})
        self.status = ActiveSupport::StringInquirer.new(json['status'].downcase)
        @locations = (json['results'] || []).map { |result| Location.new(result) }
      end

      def all
        @locations
      end

      def each(&block)
        all.each &block
      end

      def [](index)
        all[index]
      end

      def last
        all.last
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
google_maps-0.3.1 lib/google_maps/geocoder/result.rb
google_maps-0.3.0 lib/google_maps/geocoder/result.rb
google_maps-0.2.0 lib/google_maps/geocoder/result.rb
google_maps-0.1.1 lib/google_maps/geocoder/result.rb
google_maps-0.1.0 lib/google_maps/geocoder/result.rb