bikeshare 0.0.6 → 0.0.7

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 +16 -2
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDVhZTYyNTljNjAzMGUwMWEwYjBiMDYwODljYTYyYzMwYTg1MjgwNA==
4
+ NjVjN2FhNjU4NWU2ZjdiYjcxODZlNTFmMmJmMDZkMmVlZWM1NDg2Mg==
5
5
  data.tar.gz: !binary |-
6
- YTM5MmJmZWIwN2QyM2JhNDlhZmNlNGI3NTRhZjk5Y2Y5N2FmMjNhZA==
6
+ MGMwMGEzYTlkNDQ4MjJkYTNjYTBiOTNkYmZjNTNjMjdjM2Y3ZDI5MA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTAzMDJhNDFlZmFlMmQxMmVkNTY3MmVjZmY0MGM5OTI2ZWY4ZmVlNTdmNDlj
10
- NDRhOTcxOTFmOTg5YWIzYzVkNWNiNjM1NzQ5OWI2OWI5NjRiMzVlMjdmMmUz
11
- MDNhZDYxZWU4YzE2MzkzNDVkMzM0YzQ2Zjk3ZmYwNzkwMGJlZWE=
9
+ MmFjNjc3ZTUxOTQ0MTg5MTI1MzUwMzIzNjk2MDJiOTJhZDZjMGUyZWRiZTBm
10
+ ZjdkM2MwZDZkNjI2NDg3OTRlYWJmYjM2OTI4ZGJiYmYxOTljN2MxMGRhM2My
11
+ M2RhZTAyOGI2MzEwM2ZiYmQ4ZGUzMTQ3MmJmMmMzM2ZjNTZjYjc=
12
12
  data.tar.gz: !binary |-
13
- Yzk1ZjUxYzQzZWExNjBkY2E0MTMyNjYzYjM0ZDY4ZTIzYmU5MWQyY2Q3NzMy
14
- YmI4Njk4NjIxNDkwMTFlOTg0NmYzMDdiMzk5ZjhlMGIxNjU2MzI0NDQ3MWQ0
15
- ZDU3YWFlZWFmYjgxMWU1ZjcyMzYyNGRmMmJjZTkzNDdkOWNlMTU=
13
+ OWRlNjNiZTI0YmYxMjUzZGIxNWVjOTM4MmExZTVlMDFmNTgwOWVjZDIzZjc3
14
+ YzM5OGVjZWEzMGJlNTM1ZmQzNGU5NjJiNjljOGE1NTY3MjcyNzZhYWRlMTM4
15
+ ZDlmMjM3MjFiOWY5ZjlmMjc4ZmNhNzU4MWFjOTJhMDJkOTVmNWE=
data/lib/bikeshare.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  class BikeShare
2
2
 
3
3
  FIRST_STATION_ID = 2
4
+ BAY_AREA_BIKE_JSON_URL = "http://bayareabikeshare.com/stations/json"
4
5
 
5
- def initialize
6
- response = JSON.parse(open("http://bayareabikeshare.com/stations/json").read)
6
+ def initialize url = nil
7
+ response_url = url || BAY_AREA_BIKE_JSON_URL
8
+
9
+ response = JSON.parse(open(response_url).read)
7
10
  @response = response["stationBeanList"]
8
11
  end
9
12
 
@@ -81,6 +84,17 @@ class BikeShare
81
84
  list.empty? ? [] : list
82
85
  end
83
86
 
87
+ def lat_and_long(station_id)
88
+ check_valid_station_id!(station_id)
89
+
90
+ station = @response.select { |station| station["id"] == station_id }
91
+
92
+ lat = station.first["latitude"]
93
+ long = station.first["longitude"]
94
+
95
+ [lat, long]
96
+ end
97
+
84
98
  private
85
99
 
86
100
  def check_valid_station_id!(station_id)
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bikeshare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zack Shapiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-06 00:00:00.000000000 Z
11
+ date: 2013-10-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Ditto
13
+ description: A Ruby wrapper for Bay Area Bike Share bike and station information.
14
14
  email: zack@zackshapiro.com
15
15
  executables: []
16
16
  extensions: []
@@ -40,5 +40,5 @@ rubyforge_project:
40
40
  rubygems_version: 2.0.7
41
41
  signing_key:
42
42
  specification_version: 4
43
- summary: A Ruby wrapper for Bay Area Bike Share station information
43
+ summary: A Ruby wrapper for Bay Area Bike Share bike and station information.
44
44
  test_files: []