Class: Airport

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/earth/air/airport.rb

Instance Method Summary collapse

Instance Method Details

#all_flights_from_here_domestic?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/earth/air/airport.rb', line 33

def all_flights_from_here_domestic?
  !international_origin?
end

#all_flights_to_here_domestic?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/earth/air/airport.rb', line 37

def all_flights_to_here_domestic?
  !international_destination?
end

#segmentsObject


virtual has_many association has_many :segments won’t work because there’s no general way to specify the correct conditions even if you get clever with it, like has_many :segments,

:class_name => 'FlightSegment',
:foreign_key => 'origin_airport_id',
:conditions => 'flight_segments.destination_airport_id = #{id}'

you get queries like “‘flight_segments`.origin_airport_id = 3654 AND (flight_segments.destination_airport_id = 3654))” in which you notice the AND which must be an OR and you can’t just do finder_sql, because that breaks any other :select



15
16
17
# File 'lib/earth/air/airport.rb', line 15

def segments
  FlightSegment.scoped :conditions => ['origin_airport_id = ? OR destination_airport_id = ?', id, id]
end

#united_states?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/earth/air/airport.rb', line 41

def united_states?
  country == Country.united_states
end