bikeshare 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/bikeshare.rb +23 -26
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmFiYzY3M2QxMzk1NjRmNDNkODgyZTg4YTEyZDQxZjcwOWI0NTFmMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTAyN2M3YTRlNWVhZDdhNTE4ZWMyNzNhNTU0ZmNkNjJiNjZkODNhNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTY5NzY1MGI4MTM0MjJlM2U2MGE4ZmU0Y2Y5NDg5MTQ4OTUwOGExMGQ2YTE5
|
10
|
+
ZDU3Yzc5YTVhMTdjOTM3MWY1ZGE3YzMwOGUwZDBkN2ExNmYzYWE3MmE1ZDIz
|
11
|
+
OTk5MTBjZjI3OTMxNThjOTdkYjgyNjAwZjFkYjFlNjBjOGJlMDQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGY1YWNhODE1MTQ4ZjJiODI2YzI5MDI3MzljYjVkMzgzZGQyNTgwYTBlODdj
|
14
|
+
MmU0NGMzYjZmMjNhNzUyNDFhZjQ4MDczMjI1YWU2N2QyMzk4MzUzZWJlNGJh
|
15
|
+
NWQ3MzU0NjJhMGQzOGIxNDA0MTNhMDc0NWExZWI1NGVmMTA3NTg=
|
data/lib/bikeshare.rb
CHANGED
@@ -9,16 +9,19 @@ class BikeShare
|
|
9
9
|
@response.last["id"]
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
if station_id >= 2 && station_id <= last_station
|
16
|
-
station = @response.select { |station| station["id"] == station_id }
|
17
|
-
station.first
|
12
|
+
def between?(min, max)
|
13
|
+
if (min >= 2 && max <= get_last_station)
|
14
|
+
return true
|
18
15
|
else
|
19
16
|
raise "Please enter a station id in between 2 and #{last_station}"
|
20
17
|
end
|
18
|
+
end
|
21
19
|
|
20
|
+
def station_info(station_id)
|
21
|
+
if station_id.between?(2, get_last_station)
|
22
|
+
station = @response.select { |station| station["id"] == station_id }
|
23
|
+
station.first
|
24
|
+
end
|
22
25
|
end
|
23
26
|
|
24
27
|
def stations(*city_name)
|
@@ -36,43 +39,39 @@ class BikeShare
|
|
36
39
|
end
|
37
40
|
|
38
41
|
def empty?(station_id)
|
39
|
-
|
40
|
-
|
41
|
-
if station_id >= 2 && station_id <= last_station
|
42
|
+
if station_id.between?(2, get_last_station)
|
42
43
|
station = @response.select { |station| station["id"] == station_id }
|
43
44
|
|
44
45
|
station.first["availableBikes"] == 0 ? true : false
|
45
|
-
else
|
46
|
-
raise "Please enter a station id in between 2 and #{last_station}"
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
50
|
-
def
|
51
|
-
|
49
|
+
def full?(station_id)
|
50
|
+
if station_id.between?(2, get_last_station)
|
51
|
+
station = @response.select { |station| station["id"] == station_id }
|
52
52
|
|
53
|
-
|
53
|
+
station.first["availableBikes"] == station.first["totalDocks"] ? true : false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def available_bikes(station_id)
|
58
|
+
if station_id.between?(2, get_last_station)
|
54
59
|
station = @response.select { |station| station["id"] == station_id }
|
60
|
+
|
55
61
|
station.first["availableBikes"]
|
56
|
-
else
|
57
|
-
raise "Please enter a station id in between 2 and #{last_station}"
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
65
|
def total_docks(station_id)
|
62
|
-
|
63
|
-
|
64
|
-
if station_id >= 2 && station_id <= last_station
|
66
|
+
if station_id.between?(2, get_last_station)
|
65
67
|
station = @response.select { |station| station["id"] == station_id }
|
68
|
+
|
66
69
|
station.first["totalDocks"]
|
67
|
-
else
|
68
|
-
raise "Please enter a station id in between 2 and #{last_station}"
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
72
73
|
def percent_available(station_id)
|
73
|
-
|
74
|
-
|
75
|
-
if station_id >= 2 && station_id <= last_station
|
74
|
+
if station_id.between?(2, get_last_station)
|
76
75
|
station = @response.select { |station| station["id"] == station_id }
|
77
76
|
|
78
77
|
available = (station.first["availableBikes"]).to_f
|
@@ -80,8 +79,6 @@ class BikeShare
|
|
80
79
|
|
81
80
|
percentage = (available * 100.0) / total
|
82
81
|
percentage.round(2)
|
83
|
-
else
|
84
|
-
raise "Please enter a station id in between 2 and #{last_station}"
|
85
82
|
end
|
86
83
|
end
|
87
84
|
|