Class: Routing::Adapter::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/routing/adapter/test.rb

Overview

Simple test adapter, that returns an array of GeoPoints with values which are based on the ones it recieved.

Instance Method Summary collapse

Instance Method Details

#calculate(geo_points) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/routing/adapter/test.rb', line 8

def calculate(geo_points)
  geo_points.collect do |point|
    lat = point[:lat]
    lng = point[:lng]

    raise ArgumentError, "latitude or longitude missing" unless lat && lng

    GeoPoint.new(
      :lat => lat,
      :lng => lng,
      :original_lat => lat,
      :original_lng => lng,
      :relative_time => 100,
      :distance => 100,
      :waypoint => true
    )
  end
end