faa 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/faa/delay_feed.rb +3 -1
- data/lib/faa.rb +1 -1
- data/test/delay_feed_test.rb +21 -21
- metadata +1 -1
data/lib/faa/delay_feed.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
class FAA::DelayFeed
|
2
2
|
FEED_URI = 'http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp'
|
3
|
+
END_TAG = '</AIRPORT_STATUS_INFORMATION>'
|
3
4
|
|
4
5
|
attr_reader :updated_at, :delays, :raw
|
5
6
|
|
6
7
|
def initialize(raw=nil)
|
7
|
-
|
8
|
+
raw = raw ? raw : FAA::DelayFeed.raw_feed.read
|
9
|
+
@raw = raw[0..raw.index(END_TAG)+END_TAG.length-1]
|
8
10
|
@delays = []
|
9
11
|
parse_xml_feed
|
10
12
|
end
|
data/lib/faa.rb
CHANGED
data/test/delay_feed_test.rb
CHANGED
@@ -106,27 +106,27 @@ class DelayFeedTest < Test::Unit::TestCase
|
|
106
106
|
delays = FAA::DelayFeed.current_delays.select { |x| x.class == FAA::Delay::GeneralDeparture }
|
107
107
|
assert_equal 6, delays.size
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
def test_delay_feed_should_find_a_polygon_air_flow_program
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
111
|
+
FakeWeb.register_uri(:get, "http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp",
|
112
|
+
:body => File.read("#{File.dirname(__FILE__)}/responses/polygon_airspace_flow.xml"))
|
113
|
+
delays = FAA::DelayFeed.current_delays.select { |x| x.is_a? FAA::Delay::AirspaceFlow }
|
114
|
+
flow = delays.first
|
115
|
+
assert_equal(flow.class, FAA::Delay::AirspaceFlow::Polygon)
|
116
|
+
assert_equal 1, delays.size
|
117
|
+
assert_equal 'FCAMU1', flow.control_element
|
118
|
+
assert_equal 'VOLUME / VOLUME', flow.reason
|
119
|
+
assert_equal Time.utc(2009, 12, 16, 12, 0, 0), flow.fca_start_time
|
120
|
+
assert_equal Time.utc(2009, 12, 23, 23, 59, 0), flow.fca_end_time
|
121
|
+
assert_equal Time.utc(2009, 12, 16, 15, 0, 0), flow.afp_start_time
|
122
|
+
assert_equal Time.utc(2009, 12, 23, 21, 59, 0), flow.afp_end_time
|
123
|
+
assert_equal 6, flow.average
|
124
|
+
assert_equal 0, flow.floor
|
125
|
+
assert_equal 600, flow.ceiling
|
126
|
+
assert_equal flow.point_lists.first.class, FAA::Delay::AirspaceFlow::Polygon::PointsList
|
127
|
+
assert_equal flow.point_lists.first.points, [ {'latitude' => 2103, 'longitude' => 8698},
|
128
|
+
{'latitude' => 2113.0, 'longitude' => 8687.0},
|
129
|
+
{'latitude' => 2093.0, 'longitude' => 8680.0}]
|
130
|
+
end
|
131
131
|
|
132
132
|
end
|