Sha256: 857fbf6f7391944cbe73f0ec5e6fe58a026ccb9025d7a3ea3e091c8336ce1b2f

Contents?: true

Size: 923 Bytes

Versions: 4

Compression:

Stored size: 923 Bytes

Contents

module Nominatim
  class Reverse < Client
    attr_reader :criteria

    def initialize
      @criteria = {}
    end

    # Returns search result or nil if no results received.
    def fetch
      body = get(Nominatim.config.reverse_url, @criteria).body
      return nil if body.empty?
      Nominatim::Place.new(body)
    end

    # Latitude string to search for.
    #
    # @param lat [String] Latitude
    # @return [Nominatim::Reverse]
    def lat(lat)
      @criteria[:lat] = lat
      self
    end

    # Longitude string to search for.
    #
    # @param lon [String] Longitude
    # @return [Nominatim::Reverse]
    def lon(lon)
      @criteria[:lon] = lon
      self
    end

    # Include a breakdown of the address into elements.
    #
    # @param bool [true, false]
    # @return [Nominatim::Reverse]
    def address_details(bool)
      @criteria[:addressdetails] = bool ? 1 : 0
      self
    end

  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
nominatim-0.0.6 lib/nominatim/reverse.rb
ruby-nominatim-1.0.0 lib/nominatim/reverse.rb
parallel588_nominatim-0.0.7 lib/nominatim/reverse.rb
nominatim-0.0.5 lib/nominatim/reverse.rb