Class: FlightCaster::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Base

Returns a new instance of Base.



5
6
7
8
# File 'lib/flightcaster/base.rb', line 5

def initialize(api_key)
  @api_key = api_key
  FlightCaster::Request.set_api_key(@api_key)
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



3
4
5
# File 'lib/flightcaster/base.rb', line 3

def api_key
  @api_key
end

Instance Method Details

#airline(id) ⇒ Object

id

The FlightCaster id
The 2 character IATA id
The 3 chracter ICAO id of the airline


21
22
23
# File 'lib/flightcaster/base.rb', line 21

def airline(id)
  perform_get("/airlines/#{id}.xml")
end

#airlines(params = {}) ⇒ Object

Params

:per_page => The number of results per page. Defaults to 30.
:page => The page of results displayed.


13
14
15
# File 'lib/flightcaster/base.rb', line 13

def airlines(params={})
  perform_get('/airlines.xml', params)
end

#airport(id) ⇒ Object

id

The FlightCaster id
The 3 character IATA id
The 4 chracter ICAO id of the airport


36
37
38
# File 'lib/flightcaster/base.rb', line 36

def airport(id)
  perform_get("/airports/#{id}.xml")
end

#airport_arrivals(id, params = {}) ⇒ Object

id

The FlightCaster id
The 3 character IATA id
The 4 chracter ICAO id of the airport

Get all arrivals at an airport.



45
46
47
# File 'lib/flightcaster/base.rb', line 45

def airport_arrivals(id, params={})
  perform_get("/airports/#{id}/arrivals.xml", params)
end

#airport_departures(id, params = {}) ⇒ Object

id

The FlightCaster id
The 3 character IATA id
The 4 chracter ICAO id of the airport

Get all departures leaving an airport.



54
55
56
# File 'lib/flightcaster/base.rb', line 54

def airport_departures(id, params={})
  perform_get("/airports/#{id}/departures.xml", params)
end

#airports(params = {}) ⇒ Object

params

:per_page => The number of results per page. Defaults to 30.
:page => The page of results displayed.


28
29
30
# File 'lib/flightcaster/base.rb', line 28

def airports(params={})
  perform_get('/airports.xml', params)
end

#delay(id) ⇒ Object

id

The FlightCaster id
The 4 character delay ICAO id. If given, the delay that is returned
is the last one reported at that station.

Returns a single delay.



179
180
181
# File 'lib/flightcaster/base.rb', line 179

def delay(id)
  perform_get("/delays/#{id}.xml")
end

#delays(params = {}) ⇒ Object

params

:per_page => The number of results per page. Defaults to 30.
:page => The page of results displayed.

Returns all delays.



170
171
172
# File 'lib/flightcaster/base.rb', line 170

def delays(params={})
  perform_get('/delays.xml', params)
end

#flight(id) ⇒ Object

id

The id given to the flight by FlightCaster


60
61
62
# File 'lib/flightcaster/base.rb', line 60

def flight(id)
  perform_get("/flights/#{id}.xml")
end

#flight_route(origin, destination, date = nil, params = {}) ⇒ Object

origin

The FlightCaster id of the airport
The 3 character airport IATA id
The 4 character airport ICAO id

destination

The FlightCaster id of the airport
The 3 character airport IATA id
The 4 character airport ICAO id

date

A Ruby Time object
A date in the format 'yearmonthday' (ex: 20100226)

Returns all flights going from one airport to another



96
97
98
99
# File 'lib/flightcaster/base.rb', line 96

def flight_route(origin, destination, date=nil, params={})
  args = [origin, 'departures', destination, format(date)].compact.join('/')
  perform_get("/airports/#{args}.xml", params)
end

#flights(params = {}) ⇒ Object

params

:per_page => The number of results per page. Defaults to 30.
:page => The page of results displayed.


67
68
69
# File 'lib/flightcaster/base.rb', line 67

def flights(params={})
  perform_get('/flights.xml', params)
end

#flights_by_airline(airline_id, flight_number = nil, date = nil, params = {}) ⇒ Object

airline_id flight_number date

A Ruby Time object
or a date in the format 'yearmonthday' (ex: 20100226)

params

:per_page => The number of results per page. Defaults to 30.
:page => The page of results displayed.


79
80
81
82
# File 'lib/flightcaster/base.rb', line 79

def flights_by_airline(airline_id, flight_number=nil, date=nil, params={})
  args = [airline_id, 'flights', flight_number, format(date)].compact.join('/')
  perform_get("/airlines/#{args}.xml", params)
end

#ground_delay(id) ⇒ Object

id

The FlightCaster id
The 4 character delay ICAO id. If given, the delay that is returned
is the last one reported at that station.

Returns a single ground delay.



148
149
150
# File 'lib/flightcaster/base.rb', line 148

def ground_delay(id)
  perform_get("/ground_delays/#{id}.xml")
end

#ground_delays(params = {}) ⇒ Object

params

:per_page => The number of results per page. Defaults to 30.
:page => The page of results displayed.

Returns a list of ground delays



139
140
141
# File 'lib/flightcaster/base.rb', line 139

def ground_delays(params={})
  perform_get('/ground_delays.xml', params)
end

#ground_stop(id) ⇒ Object

id

The FlightCaster id
The 4 character stop ICAO id. If given, the stop that is returned
is the last one reported at that station.

Returns a single ground stop.



162
163
164
# File 'lib/flightcaster/base.rb', line 162

def ground_stop(id)
  perform_get("/ground_stops/#{id}.xml")
end

#ground_stops(params = {}) ⇒ Object

Returns all ground stops, limited to 50 results.



153
154
155
# File 'lib/flightcaster/base.rb', line 153

def ground_stops(params={})
  perform_get('/ground_stops.xml', params)
end

#metar(id) ⇒ Object

id

The FlightCaster id
The 4 character metar ICAO id. If given the metar that is returned
is the last one reported at that station.

Returns metar specified by the given id.



114
115
116
# File 'lib/flightcaster/base.rb', line 114

def metar(id)
  perform_get("/metars/#{id}.xml")
end

#metars(params = {}) ⇒ Object

params

:per_page => The number of results per page. Defaults to 30.
:page => The page of results displayed.

Returns all metars



105
106
107
# File 'lib/flightcaster/base.rb', line 105

def metars(params={})
  perform_get('/metars.xml', params)
end

#taf(id) ⇒ Object

id

The FlightCaster id
The 4 character taf ICAO id. If given the taf that is returned
is the last one reported at that station.

Returns taf specified by the given id.



131
132
133
# File 'lib/flightcaster/base.rb', line 131

def taf(id)
  perform_get("/tafs/#{id}.xml")
end

#tafs(params = {}) ⇒ Object

params

:per_page => The number of results per page. Defaults to 30.
:page => The page of results displayed.

Returns all tafs



122
123
124
# File 'lib/flightcaster/base.rb', line 122

def tafs(params={})
  perform_get('/tafs.xml', params)
end