cumtd 0.0.0
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 +7 -0
- data/lib/cumtd.rb +43 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 94f031a775a83336a3b53c5f9467c031fbe3906b
|
4
|
+
data.tar.gz: b22b5af9fa439244773f77b2da7011f0da29c517
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b00db28c5b8d597e65129b982e91f33738a14a62eb6575ae266cdb7be3625673bae7262e673a9478d836eed7c829732bd92c7d086cab978a367a9764735d0e05
|
7
|
+
data.tar.gz: 29ecdbfbab97529a877f013184bbe657d29cb5d7c7174a7670d783b13ba5e36198a476f51708ed1ea506c4165fec9c903adcd6bd18846c7196758ffb318ff270
|
data/lib/cumtd.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
class CUMTD
|
3
|
+
include HTTParty
|
4
|
+
base_uri 'developer.cumtd.com/api/v2.2/json'
|
5
|
+
def initialize(api_key)
|
6
|
+
@api_key = api_key
|
7
|
+
end
|
8
|
+
|
9
|
+
def api_key
|
10
|
+
@api_key
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_stops(lat, lon)
|
14
|
+
response = self.class.get("/GetStopsByLatLon?key=#{api_key}&lat=#{lat}&lon=#{lon}")
|
15
|
+
return stops = response["stops"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def print_all_departures(stops)
|
19
|
+
stops.each do |stop|
|
20
|
+
deps = get_departures_by_stop(stop["stop_id"])
|
21
|
+
stop_t = stop
|
22
|
+
print_departures(deps, stop_t)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_routes_by_stop(stop_id)
|
27
|
+
response = self.class.get("/GetRoutesByStop?key=#{api_key}&stop_id=#{stop_id}")
|
28
|
+
return response.parsed_response["routes"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_departures_by_stop(stop_id)
|
32
|
+
response = self.class.get("/GetDeparturesByStop?key=#{api_key}&stop_id=#{stop_id}")
|
33
|
+
return departures = response.parsed_response["departures"]
|
34
|
+
end
|
35
|
+
|
36
|
+
def print_departures(departures, stop)
|
37
|
+
puts stop["stop_name"] unless departures == []
|
38
|
+
departures.each do |departure|
|
39
|
+
puts departure["headsign"] + " " + departure["expected_mins"].to_s + "mins"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cumtd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brett Jackson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: An interface to CUMTD's API.
|
14
|
+
email: brett@brettjackson.org
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/cumtd.rb
|
20
|
+
homepage: http://rubygems.org/gems/cumtd
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.0.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: CUMTD API wrapper
|
44
|
+
test_files: []
|