Class: Freerider

Inherits:
Object
  • Object
show all
Defined in:
lib/freerider.rb,
lib/freerider/version.rb

Overview

Process values from car2go API calls

Constant Summary collapse

TC =
'twincities'
VERSION =
'0.0.4'

Instance Method Summary collapse

Constructor Details

#initialize(location, consumer_key = ENV['CONSUMER_KEY'], from_location = ENV['FROM_LOCATION']) ⇒ Freerider

Returns a new instance of Freerider.



9
10
11
12
13
14
# File 'lib/freerider.rb', line 9

def initialize(location,
               consumer_key = ENV['CONSUMER_KEY'],
               from_location = ENV['FROM_LOCATION'])
  @car2go = Caruby2go.new(consumer_key, default_if_empty(location, TC))
  @geolocutor = Geolocutor.new(from_location)
end

Instance Method Details

#find_vehicles(upper_fuel_threshold = 25, radius = 100) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/freerider.rb', line 16

def find_vehicles(upper_fuel_threshold = 25, radius = 100)
  upper_fuel_threshold = default_if_empty(upper_fuel_threshold, 25)
  radius = default_if_empty(radius, 100)
  (@car2go.vehicles.select do |vehicle|
    within_fuel_range(vehicle, upper_fuel_threshold) && within_radius(vehicle, radius)
   end
  ).compact
end