metra_schedule 0.1 → 0.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.
data/README.rdoc CHANGED
@@ -1,6 +1,16 @@
1
1
  = metra_schedule: A library to access the Chicago Metra schedule information as Ruby objects.
2
2
 
3
- CURRENTLY ONLY THE UNION PACIFIC NORTHWEST LINE IS SUPPORTED. More coming soon!
3
+ Supported Lines:
4
+ Union Pacific Northwest => :up_nw
5
+ Union Pacific North => :up_n
6
+ North Central Service => :ncs
7
+ Milwaukee District West => :md_w
8
+ Union Pacific West => :up_w
9
+ BNSF Railway => :bnsf
10
+ Heritage Corrider => :hc
11
+ Rock Island District => :ri
12
+ Metra Electric District => :me
13
+
4
14
 
5
15
  metra_schedule provides:
6
16
 
@@ -53,7 +63,7 @@ train.bike_limit :: Maximum number of bikes per train. nil if no limit.
53
63
 
54
64
  Current supported lines:
55
65
 
56
- === Union Pacific Northwest
66
+ === Union Pacific Northwest => :up_nw
57
67
 
58
68
  stations:
59
69
 
@@ -81,3 +91,244 @@ stations:
81
91
  :mchenry,
82
92
  :harvard
83
93
 
94
+
95
+ === Union Pacific North => :up_n
96
+
97
+ stations:
98
+
99
+ :ogilve,
100
+ :clyborn,
101
+ :ravenswood,
102
+ :rogers_park,
103
+ :evanston_main_street,
104
+ :evanston_davis_street,
105
+ :evanston_central_street,
106
+ :wilmette,
107
+ :kenilworth,
108
+ :indian_hill,
109
+ :winnetka,
110
+ :hubbard_woods,
111
+ :glencoe,
112
+ :braeside,
113
+ :ravinia_park,
114
+ :ravinia,
115
+ :highland_park,
116
+ :highwood,
117
+ :fort_sheridan,
118
+ :lake_forest,
119
+ :lake_bluff,
120
+ :greate_lakes,
121
+ :north_chicago,
122
+ :waukegan,
123
+ :zion,
124
+ :winthrop_harbor,
125
+ :kenosha
126
+
127
+
128
+ === North Central Service => :ncs
129
+
130
+ stations:
131
+
132
+ :union_station,
133
+ :western_avenue,
134
+ :river_grove,
135
+ :franklin_park,
136
+ :schiller_park,
137
+ :rosemont,
138
+ :ohare_transfer,
139
+ :prospect_heights,
140
+ :wheeling,
141
+ :buffalo_grove,
142
+ :prairie_view,
143
+ :vernon_hills,
144
+ :mundelein,
145
+ :libertyville,
146
+ :grayslake,
147
+ :round_lake_beach,
148
+ :lake_villa,
149
+ :antioch
150
+
151
+
152
+ === Milwaukee District West => :md_w
153
+
154
+ stations:
155
+
156
+ :union_station,
157
+ :western_avenue,
158
+ :grand_cicero,
159
+ :hanson_park,
160
+ :galewood,
161
+ :mars,
162
+ :mont_clare,
163
+ :elmwood_park,
164
+ :river_park,
165
+ :franklin_park,
166
+ :mannheim,
167
+ :bensenville,
168
+ :wood_dale,
169
+ :itasca,
170
+ :medinah,
171
+ :roselle,
172
+ :schaumburg,
173
+ :hanover_park,
174
+ :bartlett,
175
+ :national_street,
176
+ :elgin,
177
+ :big_timber
178
+
179
+
180
+ === Union Pacific West => :up_w
181
+
182
+ stations:
183
+
184
+ :ogilve,
185
+ :kedzie,
186
+ :oak_park,
187
+ :river_forest,
188
+ :maywood,
189
+ :melrose_park,
190
+ :bellwood,
191
+ :berkeley,
192
+ :elmhurst,
193
+ :villa_park,
194
+ :lombard,
195
+ :glen_ellyn,
196
+ :college_avenue,
197
+ :wheaton,
198
+ :winfield,
199
+ :west_chicago,
200
+ :geneva,
201
+ :la_fox,
202
+ :elburn
203
+
204
+
205
+ === BNSF Railway => :bnsf
206
+
207
+ stations:
208
+
209
+ :union_station,
210
+ :halsted,
211
+ :western_avenue,
212
+ :cicero,
213
+ :lavergne,
214
+ :berwyn,
215
+ :harlem_ave,
216
+ :riverside,
217
+ :hollywood,
218
+ :brookfield,
219
+ :congress_park,
220
+ :lagrange_road,
221
+ :lagrange_stone_avenue,
222
+ :western_springs,
223
+ :highlands,
224
+ :hinsdale,
225
+ :west_hinsdale,
226
+ :clarendon_hills,
227
+ :westmont,
228
+ :fairview_avenue,
229
+ :downers_grove_main_street,
230
+ :belmont,
231
+ :lisle,
232
+ :naperville,
233
+ :route_59,
234
+ :aurora
235
+
236
+
237
+ === Heritage Corrider => :hc
238
+
239
+ stations:
240
+
241
+ :union_station,
242
+ :summit,
243
+ :willow_springs,
244
+ :lemont,
245
+ :lockport,
246
+ :joliet
247
+
248
+
249
+ === Rock Island District => :ri
250
+
251
+ stations:
252
+
253
+ :chicago_lasalle_station,
254
+ :gresham,
255
+ :longwood,
256
+ :washington_heights,
257
+ :brainerd,
258
+ :beverly_hills_91_street,
259
+ :beverly_hills_95_street,
260
+ :beverly_hills_99_street,
261
+ :beverly_hills_103_street,
262
+ :beverly_hills_107_street,
263
+ :morgan_park_111_street,
264
+ :morgan_park_115_street,
265
+ :street_119,
266
+ :street_123,
267
+ :prairie_street,
268
+ :blue_island,
269
+ :robbins,
270
+ :midlothian,
271
+ :oak_forest,
272
+ :tinley_park,
273
+ :tinley_park_80_avenue,
274
+ :hickory_creek,
275
+ :mokena,
276
+ :new_lenox,
277
+ :joliet
278
+
279
+
280
+ === Metra Electric District => :me
281
+
282
+ stations:
283
+
284
+ :milennium_station,
285
+ :van_buren_street,
286
+ :museum_campus,
287
+ :street_18,
288
+ :mccormick_place,
289
+ :street_27,
290
+ :street_47,
291
+ :street_51_53,
292
+ :street_55_56_57,
293
+ :street_59,
294
+ :street_63,
295
+ :street_75,
296
+ :street_79,
297
+ :street_83,
298
+ :street_87,
299
+ :street_91,
300
+ :street_95,
301
+ :street_103,
302
+ :street_107,
303
+ :street_111,
304
+ :street_115,
305
+ :riverdale,
306
+ :ivanhoe,
307
+ :street_147,
308
+ :harvey,
309
+ :hazel_crest,
310
+ :calumet,
311
+ :homewood,
312
+ :flossmoor,
313
+ :olympia_fields,
314
+ :street_211,
315
+ :matteson,
316
+ :richton_park,
317
+ :university_park,
318
+ :stony_island,
319
+ :bryn_mawr,
320
+ :south_shore,
321
+ :windsor_park,
322
+ :street_79,
323
+ :street_83,
324
+ :street_87,
325
+ :street_93,
326
+ :state_street,
327
+ :stewart_ridge,
328
+ :west_pullman,
329
+ :racine,
330
+ :ashland,
331
+ :burr_oak,
332
+ :blue_island
333
+
334
+
data/lib/metra/parser.rb CHANGED
@@ -27,12 +27,18 @@ module MetraSchedule
27
27
  def seperate_tables
28
28
  tables = @html_doc.css('table.schedule')
29
29
  @tables = []
30
- @tables.push ({:schedule => :weekday, :direction => :inbound, :tables => [tables[0..1]].flatten})
31
- @tables.push ({:schedule => :saturday, :direction => :inbound, :tables => [tables[2]].flatten})
32
- @tables.push ({:schedule => :sunday, :direction => :inbound, :tables => [tables[3]].flatten})
33
- @tables.push ({:schedule => :weekday, :direction => :outbound, :tables => [tables[4..6]].flatten})
34
- @tables.push ({:schedule => :saturday, :direction => :outbound, :tables => [tables[7]].flatten})
35
- @tables.push ({:schedule => :sunday, :direction => :outbound, :tables => [tables[8]].flatten})
30
+ @tables.push ({:schedule => :weekday, :direction => :inbound, :tables => [tables[@line[:tables][:weekday_inbound]]].flatten}) \
31
+ if @line[:tables].has_key?(:weekday_inbound)
32
+ @tables.push ({:schedule => :saturday, :direction => :inbound, :tables => [tables[@line[:tables][:saturday_inbound]]].flatten}) \
33
+ if @line[:tables].has_key?(:saturday_inbound)
34
+ @tables.push ({:schedule => :sunday, :direction => :inbound, :tables => [tables[@line[:tables][:sunday_inbound]]].flatten}) \
35
+ if @line[:tables].has_key?(:sunday_inbound)
36
+ @tables.push ({:schedule => :weekday, :direction => :outbound, :tables => [tables[@line[:tables][:weekday_outbound]]].flatten}) \
37
+ if @line[:tables].has_key?(:weekday_outbound)
38
+ @tables.push ({:schedule => :saturday, :direction => :outbound, :tables => [tables[@line[:tables][:saturday_outbound]]].flatten}) \
39
+ if @line[:tables].has_key?(:saturday_outbound)
40
+ @tables.push ({:schedule => :sunday, :direction => :outbound, :tables => [tables[@line[:tables][:sunday_outbound]]].flatten}) \
41
+ if @line[:tables].has_key?(:sunday_outbound)
36
42
  end
37
43
 
38
44
  def make_trains
@@ -2,6 +2,7 @@ module MetraSchedule
2
2
  module TrainData
3
3
  attr_reader :LINES
4
4
 
5
+ ### Stations MUST be listed in outbound direction for the parser to function correctly!
5
6
  LINES = {
6
7
  :up_nw => {
7
8
  :name => "Union Pacific Northwest",
@@ -30,7 +31,263 @@ module MetraSchedule
30
31
  :woodstock,
31
32
  :mchenry,
32
33
  :harvard
33
- ]
34
+ ],
35
+ :tables => {:weekday_inbound => 0..1, :saturday_inbound => 2, :sunday_inbound => 3, \
36
+ :weekday_outbound => 4..6, :saturday_outbound => 7, :sunday_outbound => 8 }
37
+ },
38
+ :up_n => {
39
+ :name => "Union Pacific North",
40
+ :url => 'http://metrarail.com/metra/en/home/maps_schedules/metra_system_map/up-n/schedule.full.html',
41
+ :stations => [
42
+ :ogilve,
43
+ :clyborn,
44
+ :ravenswood,
45
+ :rogers_park,
46
+ :evanston_main_street,
47
+ :evanston_davis_street,
48
+ :evanston_central_street,
49
+ :wilmette,
50
+ :kenilworth,
51
+ :indian_hill,
52
+ :winnetka,
53
+ :hubbard_woods,
54
+ :glencoe,
55
+ :braeside,
56
+ :ravinia_park,
57
+ :ravinia,
58
+ :highland_park,
59
+ :highwood,
60
+ :fort_sheridan,
61
+ :lake_forest,
62
+ :lake_bluff,
63
+ :greate_lakes,
64
+ :north_chicago,
65
+ :waukegan,
66
+ :zion,
67
+ :winthrop_harbor,
68
+ :kenosha
69
+ ],
70
+ :tables => {:weekday_inbound => 0..2, :saturday_inbound => 3, :sunday_inbound => 4, \
71
+ :weekday_outbound => 5..7, :saturday_outbound => 8, :sunday_outbound => 9 }
72
+ },
73
+ :ncs => {
74
+ :name => "North Central Service",
75
+ :url => 'http://metrarail.com/metra/en/home/maps_schedules/metra_system_map/ncs/schedule.full.html',
76
+ :stations => [
77
+ :union_station,
78
+ :western_avenue,
79
+ :river_grove,
80
+ :franklin_park,
81
+ :schiller_park,
82
+ :rosemont,
83
+ :ohare_transfer,
84
+ :prospect_heights,
85
+ :wheeling,
86
+ :buffalo_grove,
87
+ :prairie_view,
88
+ :vernon_hills,
89
+ :mundelein,
90
+ :libertyville,
91
+ :grayslake,
92
+ :round_lake_beach,
93
+ :lake_villa,
94
+ :antioch
95
+ ],
96
+ :tables => {:weekday_inbound => 0, :weekday_outbound => 1 }
97
+ },
98
+ :md_w => {
99
+ :name => "Milwaukee District West",
100
+ :url => 'http://metrarail.com/metra/en/home/maps_schedules/metra_system_map/md-w/schedule.full.html',
101
+ :stations => [
102
+ :union_station,
103
+ :western_avenue,
104
+ :grand_cicero,
105
+ :hanson_park,
106
+ :galewood,
107
+ :mars,
108
+ :mont_clare,
109
+ :elmwood_park,
110
+ :river_park,
111
+ :franklin_park,
112
+ :mannheim,
113
+ :bensenville,
114
+ :wood_dale,
115
+ :itasca,
116
+ :medinah,
117
+ :roselle,
118
+ :schaumburg,
119
+ :hanover_park,
120
+ :bartlett,
121
+ :national_street,
122
+ :elgin,
123
+ :big_timber
124
+ ],
125
+ :tables => {:weekday_inbound => 0..1, :saturday_inbound => 2, :sunday_inbound => 3, \
126
+ :weekday_outbound => 4..5, :saturday_outbound => 6, :sunday_outbound => 7 }
127
+ },
128
+ :up_w => {
129
+ :name => "Union Pacific West",
130
+ :url => 'http://metrarail.com/metra/en/home/maps_schedules/metra_system_map/up-w/schedule.full.html',
131
+ :stations => [
132
+ :ogilve,
133
+ :kedzie,
134
+ :oak_park,
135
+ :river_forest,
136
+ :maywood,
137
+ :melrose_park,
138
+ :bellwood,
139
+ :berkeley,
140
+ :elmhurst,
141
+ :villa_park,
142
+ :lombard,
143
+ :glen_ellyn,
144
+ :college_avenue,
145
+ :wheaton,
146
+ :winfield,
147
+ :west_chicago,
148
+ :geneva,
149
+ :la_fox,
150
+ :elburn
151
+ ],
152
+ :tables => {:weekday_inbound => 0..1, :saturday_inbound => 2, :sunday_inbound => 3, \
153
+ :weekday_outbound => 4..5, :saturday_outbound => 6, :sunday_outbound => 7 }
154
+ },
155
+ :bnsf => {
156
+ :name => "BNSF Railway",
157
+ :url => 'http://metrarail.com/metra/en/home/maps_schedules/metra_system_map/bnsf/schedule.full.html',
158
+ :stations => [
159
+ :union_station,
160
+ :halsted,
161
+ :western_avenue,
162
+ :cicero,
163
+ :lavergne,
164
+ :berwyn,
165
+ :harlem_ave,
166
+ :riverside,
167
+ :hollywood,
168
+ :brookfield,
169
+ :congress_park,
170
+ :lagrange_road,
171
+ :lagrange_stone_avenue,
172
+ :western_springs,
173
+ :highlands,
174
+ :hinsdale,
175
+ :west_hinsdale,
176
+ :clarendon_hills,
177
+ :westmont,
178
+ :fairview_avenue,
179
+ :downers_grove_main_street,
180
+ :belmont,
181
+ :lisle,
182
+ :naperville,
183
+ :route_59,
184
+ :aurora
185
+ ],
186
+ :tables => {:weekday_inbound => 0..2, :saturday_inbound => 3, :sunday_inbound => 4, \
187
+ :weekday_outbound => 5..7, :saturday_outbound => 8, :sunday_outbound => 9 }
188
+ },
189
+ :hc => {
190
+ :name => "Heritage Corridor",
191
+ :url => 'http://metrarail.com/metra/en/home/maps_schedules/metra_system_map/hc/schedule.full.html',
192
+ :stations => [
193
+ :union_station,
194
+ :summit,
195
+ :willow_springs,
196
+ :lemont,
197
+ :lockport,
198
+ :joliet
199
+ ],
200
+ :tables => {:weekday_inbound => 0, :weekday_outbound => 1 }
201
+ },
202
+ :ri => {
203
+ :name => "Rock Island District",
204
+ :url => 'http://metrarail.com/metra/en/home/maps_schedules/metra_system_map/ri/schedule.full.html',
205
+ :stations => [
206
+ :chicago_lasalle_station,
207
+ :gresham,
208
+ :longwood,
209
+ :washington_heights,
210
+ :brainerd,
211
+ :beverly_hills_91_street,
212
+ :beverly_hills_95_street,
213
+ :beverly_hills_99_street,
214
+ :beverly_hills_103_street,
215
+ :beverly_hills_107_street,
216
+ :morgan_park_111_street,
217
+ :morgan_park_115_street,
218
+ :street_119,
219
+ :street_123,
220
+ :prairie_street,
221
+ :blue_island,
222
+ :robbins,
223
+ :midlothian,
224
+ :oak_forest,
225
+ :tinley_park,
226
+ :tinley_park_80_avenue,
227
+ :hickory_creek,
228
+ :mokena,
229
+ :new_lenox,
230
+ :joliet
231
+ ],
232
+ :tables => {:weekday_inbound => 0..2, :saturday_inbound => 3, :sunday_inbound => 4, \
233
+ :weekday_outbound => 5..7, :saturday_outbound => 8, :sunday_outbound => 9 }
234
+ },
235
+ :me => {
236
+ :name => "Metra Electric District",
237
+ :url => 'http://metrarail.com/metra/en/home/maps_schedules/metra_system_map/me/schedule.full.html',
238
+ :stations => [
239
+ :milennium_station,
240
+ :van_buren_street,
241
+ :museum_campus,
242
+ :street_18,
243
+ :mccormick_place,
244
+ :street_27,
245
+ :street_47,
246
+ :street_51_53,
247
+ :street_55_56_57,
248
+ :street_59,
249
+ :street_63,
250
+ :street_75,
251
+ :street_79,
252
+ :street_83,
253
+ :street_87,
254
+ :street_91,
255
+ :street_95,
256
+ :street_103,
257
+ :street_107,
258
+ :street_111,
259
+ :street_115,
260
+ :riverdale,
261
+ :ivanhoe,
262
+ :street_147,
263
+ :harvey,
264
+ :hazel_crest,
265
+ :calumet,
266
+ :homewood,
267
+ :flossmoor,
268
+ :olympia_fields,
269
+ :street_211,
270
+ :matteson,
271
+ :richton_park,
272
+ :university_park,
273
+ :stony_island,
274
+ :bryn_mawr,
275
+ :south_shore,
276
+ :windsor_park,
277
+ :street_79,
278
+ :street_83,
279
+ :street_87,
280
+ :street_93,
281
+ :state_street,
282
+ :stewart_ridge,
283
+ :west_pullman,
284
+ :racine,
285
+ :ashland,
286
+ :burr_oak,
287
+ :blue_island
288
+ ],
289
+ :tables => {:weekday_inbound => 0..5, :saturday_inbound => 6..9, :sunday_inbound => 10..11, \
290
+ :weekday_outbound => 12..17, :saturday_outbound => 18..21, :sunday_outbound => 22..23 }
34
291
  }
35
292
  }
36
293
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metra_schedule
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: "0.2"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Smith