Class: SearchResults

Inherits:
Object
  • Object
show all
Defined in:
lib/FlightXML2REST.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(searchResult = nil) ⇒ SearchResults

Returns a new instance of SearchResults.



2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
# File 'lib/FlightXML2REST.rb', line 2253

def initialize(searchResult = nil)
  begin
    rawSearchResult = JSON.parse(searchResult)
    searchResult = rawSearchResult['SearchResult']
    @searchResult = InFlightStruct.new([], searchResult['next_offset'])
    searchResult['aircraft'].each do |aircraft|
      @searchResult.aircraft << InFlightAircraftStruct.new(aircraft['altitude'],
                                                     aircraft['altitudeChange'],
                                                     aircraft['altitudeStatus'],
                                                     aircraft['departureTime'],
                                                     aircraft['destination'],
                                                     aircraft['faFlightID'],
                                                     aircraft['firstPositionTime'],
                                                     aircraft['groundspeed'],
                                                     aircraft['heading'],
                                                     aircraft['highLatitude'],
                                                     aircraft['highLongitude'],
                                                     aircraft['ident'],
                                                     aircraft['latitude'],
                                                     aircraft['longitude'],
                                                     aircraft['lowLatitude'],
                                                     aircraft['lowLongitude'],
                                                     aircraft['origin'],
                                                     aircraft['prefix'],
                                                     aircraft['suffix'],
                                                     aircraft['timeout'],
                                                     aircraft['timestamp'],
                                                     aircraft['type'],
                                                     aircraft['updateType'],
                                                     aircraft['waypoints']
                                                    )
    end
  rescue
      raise FlightAwareError.new(rawSearchResult['error']).error
  end
end

Instance Attribute Details

#searchResultObject

Returns the value of attribute searchResult.



2252
2253
2254
# File 'lib/FlightXML2REST.rb', line 2252

def searchResult
  @searchResult
end