ierail 0.2 → 0.3

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.
Files changed (2) hide show
  1. data/lib/ierail.rb +39 -0
  2. metadata +1 -1
data/lib/ierail.rb CHANGED
@@ -162,4 +162,43 @@ class IERail
162
162
  end
163
163
  retval
164
164
  end
165
+
166
+ # Get direction-specific train information for a particular station, by station name.
167
+ # This gives data on trains through that station
168
+ # Returns array of StationData objects, and each object responds to
169
+ # {
170
+ # obj#servertime =>"2012-01-20T10:03:33.777",
171
+ # obj#traincode =>"E909",
172
+ # obj#name / obj#station_name =>"Glenageary",
173
+ # obj#code / obj#station_code =>"GLGRY",
174
+ # obj#query_time =>"10:03:33",
175
+ # obj#train_date =>"20 Jan 2012",
176
+ # obj#origin => {:name => "Bray", :time => "09:55"}
177
+ # obj#destination => {:name => "Howth", :time => "11:03"}
178
+ # obj#status =>"En Route",
179
+ # obj#last_location =>"Arrived Killiney",
180
+ # obj#duein / obj#due_in =>"6",
181
+ # obj#late =>"0",
182
+ # obj#late? => 0 / 1
183
+ # obj#arrival => {:scheduled => "10:09", :expected => "10:09"}
184
+ # obj#departure => {:scheduled => "10:09", :expected => "10:09"}
185
+ # obj#direction => "Northbound",
186
+ # obj#train_type => "DART",
187
+ # }
188
+ # Returns empty array if no data.
189
+ #
190
+
191
+ def method_missing(name, *args, &block)
192
+ # Only handle *bound_from (e.g northbound_from / southbound_from)
193
+ if name =~ /bound_from/
194
+ direction = name.to_s.split('_').first.capitalize
195
+
196
+ ier = IERailGet.new("getStationDataByNameXML?StationDesc=#{args.first}", "arrayofobjstationdata", "objstationdata")
197
+ retval = []
198
+ ier.response.each do |sd|
199
+ retval << StationData.new(sd) if sd['Direction'] == direction
200
+ end
201
+ retval
202
+ end
203
+ end
165
204
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ierail
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.2"
5
+ version: "0.3"
6
6
  platform: ruby
7
7
  authors:
8
8
  - Oisin Hurley