Class: Nominatim::Reverse

Inherits:
Client
  • Object
show all
Defined in:
lib/nominatim/reverse.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Client

#get

Constructor Details

#initializeReverse

Returns a new instance of Reverse.



5
6
7
# File 'lib/nominatim/reverse.rb', line 5

def initialize
  @criteria = {}
end

Instance Attribute Details

#criteriaObject (readonly)

Returns the value of attribute criteria.



3
4
5
# File 'lib/nominatim/reverse.rb', line 3

def criteria
  @criteria
end

Instance Method Details

#address_details(bool) ⇒ Nominatim::Reverse

Include a breakdown of the address into elements.

Parameters:

  • bool (true, false)

Returns:



38
39
40
41
# File 'lib/nominatim/reverse.rb', line 38

def address_details(bool)
  @criteria[:addressdetails] = bool ? 1 : 0
  self
end

#fetchObject

Returns search result or nil if no results received.



10
11
12
13
14
# File 'lib/nominatim/reverse.rb', line 10

def fetch
  body = get(Nominatim.config.reverse_url, @criteria).body
  return nil if body.empty?
  Nominatim::Place.new(body)
end

#lat(lat) ⇒ Nominatim::Reverse

Latitude string to search for.

Parameters:

  • lat (String)

    Latitude

Returns:



20
21
22
23
# File 'lib/nominatim/reverse.rb', line 20

def lat(lat)
  @criteria[:lat] = lat
  self
end

#lon(lon) ⇒ Nominatim::Reverse

Longitude string to search for.

Parameters:

  • lon (String)

    Longitude

Returns:



29
30
31
32
# File 'lib/nominatim/reverse.rb', line 29

def lon(lon)
  @criteria[:lon] = lon
  self
end