Module: OSRM

Defined in:
lib/osrm.rb,
lib/osrm/query.rb,
lib/osrm/route.rb,
lib/osrm/version.rb,
lib/osrm/configuration.rb

Defined Under Namespace

Classes: Configuration, Query, Route

Constant Summary collapse

VERSION =
'0.5.0'

Class Method Summary collapse

Class Method Details

.configurationObject



11
12
13
# File 'lib/osrm.rb', line 11

def self.configuration
  Configuration.instance
end

.configure(options) ⇒ Object



7
8
9
# File 'lib/osrm.rb', line 7

def self.configure(options)
  Configuration.instance.merge!(options)
end

.method_missing(method, *arguments, **keyword_arguments) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/osrm.rb', line 26

def self.method_missing(method, *arguments, **keyword_arguments)
  if /^(?<delegate>routes?)_by_(?<profile>[a-z]+)$/ =~ method
    keyword_arguments[:profile] = profile
    method(delegate).call(*arguments, **keyword_arguments)
  else
    super
  end
end

.respond_to_missing?(method) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/osrm.rb', line 35

def self.respond_to_missing?(method, *)
  /^routes?_by_[a-z]+$/.match(method) || super
end

.route(*locations, overview: nil, profile: nil) ⇒ Object



20
21
22
23
24
# File 'lib/osrm.rb', line 20

def self.route(*locations, overview: nil, profile: nil)
  Query.new(*locations)
       .execute(alternatives: false, overview: overview, profile: profile)
       .first
end

.routes(*locations, overview: nil, profile: nil) ⇒ Object



15
16
17
18
# File 'lib/osrm.rb', line 15

def self.routes(*locations, overview: nil, profile: nil)
  Query.new(*locations)
       .execute(alternatives: true, overview: overview, profile: profile)
end