Class: GetAlertsResults

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(getAlertsResult = nil) ⇒ GetAlertsResults

Returns a new instance of GetAlertsResults.



1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
# File 'lib/FlightXML2REST.rb', line 1275

def initialize(getAlertsResult = nil)
  begin
    rawGetAlertsResult = JSON.parse(getAlertsResult)
    getAlertsResult = rawGetAlertsResult['GetAlertsResult']
    @getAlertsResult = FlightAlertListing.new([], getAlertsResult['num_alerts'])
    getAlertsResult['alerts'].each do |alert|
      myAlert = FlightAlertEntry.new(alert['aircrafttype'],
                                     alert['alert_changed'],
                                     alert['alert_created'],
                                     alert['alert_id'],
                                     [],
                                     alert['date_end'],
                                     alert['date_start'],
                                     alert['description'],
                                     alert['destination'],
                                     alert['enabled'],
                                     alert['ident'],
                                     alert['origin'],
                                     alert['type'],
                                     alert['user_ident']
                                    )
      alert['channels'].each do |channel|
        myAlert.channels << FlightAlertChannel.new(channel['channel_id'],
                                          channel['channel_name'],
                                          channel['e_arrival'],
                                          channel['e_cancelled'],
                                          channel['e_departure'],
                                          channel['e_diverted'],
                                          channel['e_filed'],
                                          channel['mask_summary'],
                                          channel['target_address']
                                         )
      end
      @getAlertsResult.alerts << myAlert
    end
  rescue
      raise FlightAwareError.new(rawGetAlertsResult['error']).error
  end
end

Instance Attribute Details

#getAlertsResultObject

Returns the value of attribute getAlertsResult.



1274
1275
1276
# File 'lib/FlightXML2REST.rb', line 1274

def getAlertsResult
  @getAlertsResult
end