velov 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57fb179c3645ce9deadf22d1a5ab73d100b7a2d9
4
- data.tar.gz: 8e9eb1b3254f3729ee67b7c3979fd4126f473bb0
3
+ metadata.gz: 5e7f516ed1ce1288fab0afc2fa6e9ca19a51c40c
4
+ data.tar.gz: c627bf702ad7daebde174a80fea10a78fe52a23c
5
5
  SHA512:
6
- metadata.gz: fbd1a46125e1128e2cb5785f14339e6dcc075bc3b2060dc54910a5d31fe56c46fd0e5360d75622a091ed7654b5162e0f462c1806b5bfc85c71577a87ec14f215
7
- data.tar.gz: f5bd27317ef9a7b87a082c4d8266f4189b53a1c5596290a8b6e3b6f64abac281f47f43fe9f4eeaf4f29a7ed113495c19f3f2b4e5849e5ce2f04905c8bbca341d
6
+ metadata.gz: df22b1b935286b403181d83c8785a291b715dd470dafa0f35ce91875c3ca746f5171022acebfb1b81a916dd066f72ae02b451abe8f8d46bfb7a4134eaeddfc42
7
+ data.tar.gz: 377cfe85860a0ebeda2d28dd809a105f908a8915779e4a4e7f481f0add22113a44238237ffb3cd323610b6f5d4cddadfa9e956416790c92159138f7b978c2735
data/README.md CHANGED
@@ -99,6 +99,12 @@ Find the nearest stations around you:
99
99
  station_list.nearest(45.8,4.9)
100
100
  ```
101
101
 
102
+ Know the distance you will walk in a specified trip
103
+
104
+ ```ruby
105
+ station_list.walking_distance([45.8,4.9],[46.1,4.8])
106
+ ```
107
+
102
108
  ## Contributing
103
109
 
104
110
  1. [Fork it](http://github.com/pbechu/velov/fork)
@@ -50,5 +50,15 @@ module Velov
50
50
  @list.map(&:available_bikes).inject(:+)
51
51
  end
52
52
 
53
+ def walking_distance(start, arrival)
54
+ start_station = self.nearest(start.first, start.last).find do |station|
55
+ station.status == "OPEN" and station.available_bikes > 0
56
+ end
57
+ arrival_station = self.nearest(arrival.first, arrival.last).find do |station|
58
+ station.status == "OPEN" and station.available_bike_stands > 0
59
+ end
60
+ start_station.distance_to(start.first, start.last) + arrival_station.distance_to(arrival.first, arrival.last)
61
+ end
62
+
53
63
  end
54
64
  end
@@ -1,3 +1,3 @@
1
1
  module Velov
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -21,4 +21,9 @@ describe Velov::StationList do
21
21
  it { expect(@station_list.available_bike_stands).to eq 3544}
22
22
  it { expect(@station_list.available_bikes).to eq 3031}
23
23
  end
24
+
25
+ describe ":walking_distance" do
26
+ it { expect(@station_list.walking_distance([45.760,4.89],[45.76,4.83])).to eq 0.09376409039870806 }
27
+ it { expect(@station_list.walking_distance([45.7645636665294000,4.8923336071821100],[45.7635730869941000,4.8319018373465500])).to_not eq 0 }
28
+ end
24
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: velov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre-Baptiste Béchu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-24 00:00:00.000000000 Z
11
+ date: 2014-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler