velov 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/velov/station_list.rb +10 -0
- data/lib/velov/version.rb +1 -1
- data/spec/station_list_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e7f516ed1ce1288fab0afc2fa6e9ca19a51c40c
|
4
|
+
data.tar.gz: c627bf702ad7daebde174a80fea10a78fe52a23c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
data/lib/velov/station_list.rb
CHANGED
@@ -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
|
data/lib/velov/version.rb
CHANGED
data/spec/station_list_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2014-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|