cumtd 0.1.1 → 0.1.2
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/lib/cumtd.rb +8 -3
- data/lib/trip.rb +13 -0
- data/lib/vehicle.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b40e29e5713b9d247b524ac5696660b8bbd0b1f
|
4
|
+
data.tar.gz: 0dd7c7fb931c2f57b8c0ce2efc7b667dff2abe26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfa8dcd9dc64a077264da61f3f93da939cbca85729d467e8148c0de23fc31f54e986fef269315dac16aa3a037307004ce641a66961b7e947cc873e3a8d53b748
|
7
|
+
data.tar.gz: c049aaa4307c92d182975bd6236f9e414d70f018f52b405517ac88df9114d60089a9cba64c470d9426d0eb3a9961a762c9c5fdbc6c2a8de18e189813566206fa
|
data/lib/cumtd.rb
CHANGED
@@ -16,7 +16,7 @@ class CUMTD
|
|
16
16
|
@@all_stops = Array.new
|
17
17
|
if stops_file
|
18
18
|
object = nil
|
19
|
-
File.open(stops_file,"rb") {|f| @@all_stops =
|
19
|
+
File.open(stops_file,"rb") {|f| @@all_stops = YAML.load(f)}
|
20
20
|
else
|
21
21
|
self.get_stops
|
22
22
|
end
|
@@ -24,13 +24,12 @@ class CUMTD
|
|
24
24
|
@@all_routes = Array.new
|
25
25
|
if routes_file
|
26
26
|
object = nil
|
27
|
-
File.open(routes_file,"rb") {|f| @@all_routes =
|
27
|
+
File.open(routes_file,"rb") {|f| @@all_routes = YAML.load(f)}
|
28
28
|
else
|
29
29
|
self.get_routes
|
30
30
|
end
|
31
31
|
|
32
32
|
unless serialize_path == :no_serialize
|
33
|
-
p File.join(serialize_path, 'stops')
|
34
33
|
serialize_stops(File.join(serialize_path, 'stops.yaml'))
|
35
34
|
serialize_routes(File.join(serialize_path, 'routes.yaml'))
|
36
35
|
end
|
@@ -61,6 +60,12 @@ class CUMTD
|
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
63
|
+
def serialize_vehicles(vehicles, file_location)
|
64
|
+
File.open(file_location, "wb") do |file|
|
65
|
+
YAML.dump(vehicles,file)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
64
69
|
def get_stops
|
65
70
|
response = self.class.get("/GetStops?key=#{@api_key}")
|
66
71
|
@@all_stops.clear
|
data/lib/trip.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'json'
|
1
2
|
class Trip < CUMTD
|
2
3
|
def initialize(json)
|
3
4
|
@trip_id = json["trip_id"]
|
@@ -9,6 +10,18 @@ class Trip < CUMTD
|
|
9
10
|
@shape_id = json["shape_id"]
|
10
11
|
end
|
11
12
|
|
13
|
+
def to_json(*a)
|
14
|
+
{
|
15
|
+
'trip_id' => @trip_id,
|
16
|
+
'trip_headsign' => @trip_headsign,
|
17
|
+
'route_id' => @route_id,
|
18
|
+
'block_id' => @block_id,
|
19
|
+
'direction' => @direction,
|
20
|
+
'service_id' => @service_id,
|
21
|
+
'shape_id' => @shape_id
|
22
|
+
}.to_json(*a)
|
23
|
+
end
|
24
|
+
|
12
25
|
def trip_id
|
13
26
|
@trip_id
|
14
27
|
end
|
data/lib/vehicle.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'json'
|
1
2
|
class Vehicle < CUMTD
|
2
3
|
def initialize(json)
|
3
4
|
@vehicle_id = json["vehicle_id"]
|
@@ -41,5 +42,14 @@ class Vehicle < CUMTD
|
|
41
42
|
def last_updated
|
42
43
|
@last_updated
|
43
44
|
end
|
45
|
+
|
46
|
+
def to_json(*a)
|
47
|
+
{
|
48
|
+
'vehicle_id' => @vehicle_id,
|
49
|
+
'lat' => @location[:lat],
|
50
|
+
'lon' => @location[:lon],
|
51
|
+
'trip' => @trip
|
52
|
+
}.to_json(*a)
|
53
|
+
end
|
44
54
|
|
45
55
|
end
|