Class: SimpleGeo::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_geo/endpoint.rb

Class Method Summary collapse

Class Method Details

.add_records(layer) ⇒ Object



15
16
17
# File 'lib/simple_geo/endpoint.rb', line 15

def add_records(layer)
  endpoint_url "records/#{layer}.json"
end

.boundary(id) ⇒ Object



56
57
58
# File 'lib/simple_geo/endpoint.rb', line 56

def boundary(id)
  endpoint_url "boundary/#{id}.json"
end

.contains(lat, lon) ⇒ Object



48
49
50
# File 'lib/simple_geo/endpoint.rb', line 48

def contains(lat, lon)
  endpoint_url "contains/#{lat},#{lon}.json"
end

.density(lat, lon, day, hour = nil) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/simple_geo/endpoint.rb', line 35

def density(lat, lon, day, hour=nil)
  if hour.nil?
    path = "density/#{day}/#{lat},#{lon}.json"
  else
    path = "density/#{day}/#{hour}/#{lat},#{lon}.json"
  end
  endpoint_url path
end

.endpoint_url(path) ⇒ Object



60
61
62
# File 'lib/simple_geo/endpoint.rb', line 60

def endpoint_url(path)
  [REALM, API_VERSION, path].join('/')
end

.history(layer, id) ⇒ Object



19
20
21
# File 'lib/simple_geo/endpoint.rb', line 19

def history(layer, id)
  endpoint_url "records/#{layer}/#{id}/history.json"
end

.layer(layer) ⇒ Object



44
45
46
# File 'lib/simple_geo/endpoint.rb', line 44

def layer(layer)
  endpoint_url "layer/#{layer}.json"
end

.nearby_address(lat, lon) ⇒ Object



31
32
33
# File 'lib/simple_geo/endpoint.rb', line 31

def nearby_address(lat, lon)
  endpoint_url "nearby/address/#{lat},#{lon}.json"
end

.nearby_coordinates(layer, lat, lon) ⇒ Object



27
28
29
# File 'lib/simple_geo/endpoint.rb', line 27

def nearby_coordinates(layer, lat, lon)
  endpoint_url "records/#{layer}/nearby/#{lat},#{lon}.json"
end

.nearby_geohash(layer, geohash) ⇒ Object



23
24
25
# File 'lib/simple_geo/endpoint.rb', line 23

def nearby_geohash(layer, geohash)
  endpoint_url "records/#{layer}/nearby/#{geohash}.json"
end

.overlaps(south, west, north, east) ⇒ Object



52
53
54
# File 'lib/simple_geo/endpoint.rb', line 52

def overlaps(south, west, north, east)
  endpoint_url "overlaps/#{south},#{west},#{north},#{east}.json"
end

.record(layer, id) ⇒ Object



6
7
8
# File 'lib/simple_geo/endpoint.rb', line 6

def record(layer, id)
  endpoint_url "records/#{layer}/#{id}.json"
end

.records(layer, ids) ⇒ Object



10
11
12
13
# File 'lib/simple_geo/endpoint.rb', line 10

def records(layer, ids)
   ids = ids.join(',')  if ids.is_a? Array
   endpoint_url "records/#{layer}/#{ids}.json"
end