Class: JetBluePlaneTracker::Airport
- Inherits:
-
Object
- Object
- JetBluePlaneTracker::Airport
- Defined in:
- lib/jetblue_plane_tracker/airport.rb
Instance Attribute Summary collapse
-
#altitude ⇒ Object
Returns the value of attribute altitude.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#dst ⇒ Object
Returns the value of attribute dst.
-
#iata ⇒ Object
Returns the value of attribute iata.
-
#icao ⇒ Object
Returns the value of attribute icao.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#name ⇒ Object
Returns the value of attribute name.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(iata, icao, name, city, country, latitude, longitude, altitude, timezone, dst) ⇒ Airport
constructor
A new instance of Airport.
- #to_json ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(iata, icao, name, city, country, latitude, longitude, altitude, timezone, dst) ⇒ Airport
Returns a new instance of Airport.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 7 def initialize(iata, icao, name, city, country, latitude, longitude, altitude, timezone, dst) self.iata = iata self.icao = icao self.name = name self.city = city self.country = country self.longitude = longitude self.latitude = latitude self.altitude = altitude self.timezone = timezone self.dst = dst end |
Instance Attribute Details
#altitude ⇒ Object
Returns the value of attribute altitude.
5 6 7 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 5 def altitude @altitude end |
#city ⇒ Object
Returns the value of attribute city.
5 6 7 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 5 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
5 6 7 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 5 def country @country end |
#dst ⇒ Object
Returns the value of attribute dst.
5 6 7 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 5 def dst @dst end |
#iata ⇒ Object
Returns the value of attribute iata.
5 6 7 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 5 def iata @iata end |
#icao ⇒ Object
Returns the value of attribute icao.
5 6 7 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 5 def icao @icao end |
#latitude ⇒ Object
Returns the value of attribute latitude.
5 6 7 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 5 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
5 6 7 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 5 def longitude @longitude end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 5 def name @name end |
#timezone ⇒ Object
Returns the value of attribute timezone.
5 6 7 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 5 def timezone @timezone end |
Class Method Details
.find(options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 51 def find(={}) file = File.read(File.('../../data/airports.json', __FILE__)) data = JSON.parse(file) airport_data = data[[:iata]] new(airport_data["iata"], airport_data["icao"], airport_data["name"], airport_data["city"], airport_data["country"], airport_data["latitude"], airport_data["longitude"], airport_data["altitude"], airport_data["timezone"], airport_data["dst"]) end |
.parse_airport_iata(airport_name) ⇒ Object
47 48 49 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 47 def parse_airport_iata(airport_name) airport_name[/[(][a-zA-Z]*[)]/, 0].gsub(/[()]/, "").strip.to_s end |
Instance Method Details
#to_json ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 30 def to_json { "iata" => self.iata, "icao" => self.icao, "name" => self.name, "city" => self.city, "country" => self.country, "latitude" => self.latitude, "longitude" => self.longitude, "altitude" => self.altitude, "timezone" => self.timezone, "dst" => self.dst }.to_json end |
#to_s ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/jetblue_plane_tracker/airport.rb', line 20 def to_s str = "" self.instance_variables.each do |var| name = var.to_s.gsub!("@", "") key = send(name) str += "#{name}: #{key}, " end str[0..str.length-3] end |