bikeshare 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/bikeshare.rb +23 -26
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWNjODliM2UwMzAzYmJkNTczM2E5MTE5YzYzNGZmNzk0MTgwNTQyYQ==
4
+ MmFiYzY3M2QxMzk1NjRmNDNkODgyZTg4YTEyZDQxZjcwOWI0NTFmMA==
5
5
  data.tar.gz: !binary |-
6
- YzgyOTBiMDU1MTRkMWFkZjY4NjAwNmQ5NjlhOThlYTNiMTc1MWQ3MQ==
6
+ OTAyN2M3YTRlNWVhZDdhNTE4ZWMyNzNhNTU0ZmNkNjJiNjZkODNhNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjQ0YzUxMGMxY2FhOGFjYjY1YjJiMjc1ZWM1NWM4YjM3Njc5MjgyOTRlNWQy
10
- NGEzY2ZkMmVkNDllMmFiODAyNTQ4YWQ1MWVkMWYwMmVlMmJjZTY1MGM3N2Ez
11
- MWM3NmY3M2YyZDE1ODZiNDgyZjFlMmVkOTQzMzM2YmMxYmYxYmM=
9
+ NTY5NzY1MGI4MTM0MjJlM2U2MGE4ZmU0Y2Y5NDg5MTQ4OTUwOGExMGQ2YTE5
10
+ ZDU3Yzc5YTVhMTdjOTM3MWY1ZGE3YzMwOGUwZDBkN2ExNmYzYWE3MmE1ZDIz
11
+ OTk5MTBjZjI3OTMxNThjOTdkYjgyNjAwZjFkYjFlNjBjOGJlMDQ=
12
12
  data.tar.gz: !binary |-
13
- MGFiNzU0Nzg5NzcwYTZkMjFmZTI4YjU1MDBhODdkN2UxZGU1YTQ3YTlkZmUy
14
- MmI1NDk0MmU5NWEzYTc4YmIzY2ZiNTM2YTkzOGMyMWNmZDJhYzFjNWY0Yzk0
15
- YTZiNWQ0NTM1ODg4MzQxMGQ1NTU3OTZiOWU4OWM1Zjk3YWI0NmY=
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 station_info(station_id)
13
- last_station = get_last_station
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
- last_station = get_last_station
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 available_bikes(station_id)
51
- last_station = get_last_station
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
- if station_id >= 2 && station_id <= last_station
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
- last_station = get_last_station
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
- last_station = get_last_station
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bikeshare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zack Shapiro