jetblue_plane_tracker 0.2.3 → 0.2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/jetblue_plane_tracker/leg.rb +36 -13
- data/lib/jetblue_plane_tracker/travel.rb +2 -2
- data/lib/jetblue_plane_tracker/version.rb +1 -1
- data/lib/jetblue_plane_tracker.rb +2 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGIwZjNmYTQ2NDVjMjlkY2U3YTZhNjU4N2JmM2UwNjE1Njg5NWQyZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTQ1YjM0OGE3NTBhNTJlNGJkNzVhNjFlZGI4Y2U5MDI5MDViYTliMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDI1NDU1YjcwOTk2NDY2MzFiNTllNTZlNzc0Y2U2ZWYwZjVjOGFhNmIxNDUw
|
10
|
+
MTYzNzJlZGNiZmQzNWNlOTA3MWU2ZDUzYmEzMTM5MWM5MTQ1MDA1OGRjNDgx
|
11
|
+
MGMzZGU3NzUwYmUzZjZlMzZiMzVhYjJkOWRhMGE0ZmVhNDI5MDY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTI5NjM3ZjQwYTNlMmI5NTQzZTgzNDVjYTU0ODgwYzFiOTE5NWE0ZDNlODY3
|
14
|
+
Y2ZjZjQ2NGRmMTA0NGFkMWZlYTU1MjYyYmVkZmFiNWFiNjdkYzA5MTA4MTEw
|
15
|
+
YTJhZWJmM2IyOWRmMDMwZWNmOTdmZGE0YzA2NWE2NTNlMWQxMGY=
|
@@ -1,14 +1,15 @@
|
|
1
1
|
module JetBluePlaneTracker
|
2
2
|
class Leg
|
3
|
-
attr_accessor :number, :date, :departure, :arrival, :status, :progress
|
3
|
+
attr_accessor :number, :date, :departure, :arrival, :status, :progress, :current_location
|
4
4
|
|
5
5
|
def initialize(number, date, departure, arrival, status)
|
6
6
|
self.number = number
|
7
7
|
self.date = date
|
8
8
|
self.departure = departure
|
9
|
-
self.arrival = arrival
|
9
|
+
self.arrival = arrival
|
10
10
|
self.status = status
|
11
11
|
self.progress = flight_tracker_progress
|
12
|
+
self.current_location = current_location
|
12
13
|
end
|
13
14
|
|
14
15
|
def to_s
|
@@ -22,28 +23,50 @@ module JetBluePlaneTracker
|
|
22
23
|
"departure" => self.departure.to_json,
|
23
24
|
"arrival" => self.arrival.to_json,
|
24
25
|
"status" => self.status,
|
25
|
-
"progress" => self.progress
|
26
|
+
"progress" => self.progress,
|
27
|
+
"current_location" => current_location
|
26
28
|
}.to_json
|
27
29
|
end
|
28
30
|
|
29
31
|
def flight_tracker_progress
|
30
32
|
min_progress = 0
|
31
33
|
max_progress = 1
|
32
|
-
progress = 0
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
progress = 0
|
35
|
+
# Arrival airport timezone (UTC)
|
36
|
+
utc = self.arrival.airport.timezone
|
37
|
+
# Convert dates to the actual arrival airport timezone
|
38
|
+
current_datetime = DateTime.now.change(:offset => utc.to_s).to_i
|
39
|
+
|
40
|
+
actual_arrival = self.arrival.actual_takeoff.change(:offset => utc.to_s).to_i
|
41
|
+
|
42
|
+
actual_departure = self.departure.actual_takeoff.change(:offset => utc.to_s).to_i
|
43
|
+
|
44
|
+
progress = (current_datetime - actual_departure).to_f / (actual_arrival - actual_departure).to_f
|
41
45
|
|
42
|
-
|
46
|
+
# Check if progress is minor than min progress or max progress
|
47
|
+
progress = (progress < min_progress) ? min_progress : progress
|
48
|
+
progress = (progress > max_progress) ? max_progress : progress
|
43
49
|
|
44
50
|
progress * 100
|
45
51
|
end
|
46
52
|
|
53
|
+
# To be tested in different coordinates
|
54
|
+
def current_location
|
55
|
+
departude_longitude = self.departure.airport.longitude.to_f
|
56
|
+
arrival_longitude = self.arrival.airport.longitude.to_f
|
57
|
+
current_progress = self.progress / 100
|
58
|
+
|
59
|
+
current_latitude = self.arrival.airport.latitude
|
60
|
+
current_longitude = get_plane_longitude(departude_longitude, arrival_longitude, current_progress)
|
61
|
+
|
62
|
+
{latitude: current_latitude, longitude: current_longitude}
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def get_plane_longitude(departurelng, arrivallng, progress)
|
67
|
+
(progress > 0) ? ((arrivallng + ((1-progress)*arrivallng)) - progress) : departurelng
|
68
|
+
end
|
69
|
+
|
47
70
|
end
|
48
71
|
|
49
72
|
end
|
@@ -5,8 +5,8 @@ module JetBluePlaneTracker
|
|
5
5
|
def initialize(airport, scheduled_takeoff, actual_takeoff, terminal, gate, temperature)
|
6
6
|
super()
|
7
7
|
self.airport = Airport.find(iata: Airport.parse_airport_iata(airport))
|
8
|
-
self.scheduled_takeoff = scheduled_takeoff
|
9
|
-
self.actual_takeoff = actual_takeoff
|
8
|
+
self.scheduled_takeoff = DateTime.parse(scheduled_takeoff)
|
9
|
+
self.actual_takeoff = DateTime.parse(actual_takeoff)
|
10
10
|
self.terminal = terminal
|
11
11
|
self.gate = gate
|
12
12
|
self.temperature = temperature
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'httparty'
|
3
|
+
require 'active_support/time'
|
3
4
|
require File.expand_path('../jetblue_plane_tracker/airport', __FILE__)
|
4
5
|
require File.expand_path('../jetblue_plane_tracker/flight', __FILE__)
|
5
6
|
require File.expand_path('../jetblue_plane_tracker/leg', __FILE__)
|
6
7
|
require File.expand_path('../jetblue_plane_tracker/travel', __FILE__)
|
7
8
|
require File.expand_path('../jetblue_plane_tracker/departure', __FILE__)
|
8
9
|
require File.expand_path('../jetblue_plane_tracker/arrival', __FILE__)
|
9
|
-
require File.expand_path('../jetblue_plane_tracker/tracker', __FILE__)
|
10
|
+
require File.expand_path('../jetblue_plane_tracker/tracker', __FILE__)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jetblue_plane_tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Díaz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: A Ruby wrapper for JetBlue flights status API
|
42
56
|
email: brian@briandiaz.me
|
43
57
|
executables: []
|