jetblue_plane_tracker 0.2.0 → 0.2.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGQ4NWU1YjQ1YzI0NmQ3N2ZiNTliYThjMDBiYmRiN2ZhYWVkZDIwZQ==
4
+ MzNiZTFjYWUwZTdiZTA1MjlkMzJmODliYWQ5YTVhYzU3MjljNDhiYQ==
5
5
  data.tar.gz: !binary |-
6
- ZmI4ZmIyM2MyZDE5ZjM4ODBkYmZjMzdhNzkwOWI4ZjkyOTAyZWM0MA==
6
+ NmQ5NDQyYWMzODc0MjZlOTIyNjBmMmY3MDcxNzQ5MTM3MzcyZDQ4OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzdiZGM3YTZiNDg0YjNkOGNlMjJmZTc5MzkwNGE1N2ZkZWU4YzMzMThjMjFm
10
- Mzg0NjRjNTk5Y2FhYjVlYjg2NDYwZjdjOWI5MTQ1ZmEzMmNlM2QyNGRhOWFk
11
- YTRkZWVjMTAxOWE5OGE4ZjdjYzViMzkyZDQ5ODEzOTM1M2MzNmY=
9
+ NjFjNTc2MmYxMGMzZDFkMDAzZjA4NzNlZTBiZGZlNzc0YWY3YWNmNzYxYWMx
10
+ MDlhNGMzNWRkMzg2YjllZmFhZmNmY2U2ODUwZTExYmE4N2NhMTEzNjRlYWQw
11
+ MDg0ODg0YWM0YjcwYzUyNTA4NzZlMGE0N2Q3MzM0YWU1YTRiYzY=
12
12
  data.tar.gz: !binary |-
13
- NzQ5ZDZmODZkODA3MDljNmM1NzdjODg0YmEwMjZhNDcyNTU5YTBiMTVjN2Ri
14
- M2E3MmYyZDM3NzNiNTVkZDQ4ZWNhMDUyNDQwYzA5NjRjODNlMTM3Njk2OTZj
15
- ZWFkMDQ5Y2E4OTY5MzBiMWRlYzI5NDAzNDlhOGNmNzBkNjg4ZDY=
13
+ NTE4ZGM5ODI1NGJlOWIyNDkwNGE3NTRmNzExNGVjYmVlYzIwMGQzY2U2ZWYw
14
+ OTBjODgxNjA5N2ViYWIzYjZjODc4Zjc2NmY1YTg4OWE1YTMzNDZhNTA4ZDk0
15
+ YTAyMGM1ODRjNWQ2NTBkZDMxYjc2M2NhOWU5NDQ1MWFmNTM5ZjI=
data/README.md CHANGED
@@ -28,11 +28,11 @@ jbtracker = JetBluePlaneTracker::Tracker.new
28
28
  Get a flight status by the departure and arrival city and its date:
29
29
 
30
30
  ```ruby
31
- flights = jbtracker.flight_status(origin: "SFO", destination: "JFK", date: "2015-31-07")
31
+ flights = jbtracker.flight_status(origin: "SFO", destination: "JFK", date: "2015-07-31")
32
32
  ```
33
33
  Get a flight status by the flight number and its date:
34
34
  ```ruby
35
- flights = jbtracker.flight_status(flight: 37, date: "2015-29-07")
35
+ flights = jbtracker.flight_status(flight: 37, date: "2015-07-29")
36
36
  ```
37
37
 
38
38
  Print flights by:
@@ -50,7 +50,7 @@ flights.map { |flight| flight.to_json }
50
50
 
51
51
  ## Suggestions
52
52
 
53
- * Date Format is ```yyyy-dd-mm```
53
+ * Date Format is ```yyyy-mm-dd```
54
54
  * Permited params are:
55
55
  * origin
56
56
  * destination
@@ -4,6 +4,7 @@ module JetBluePlaneTracker
4
4
  def initialize(airport, scheduled_takeoff, actual_takeoff, terminal, gate, temperature)
5
5
  super(airport, scheduled_takeoff, actual_takeoff, terminal, gate, temperature)
6
6
  end
7
+
7
8
 
8
9
  class << self
9
10
 
@@ -1,6 +1,6 @@
1
1
  module JetBluePlaneTracker
2
2
  class Leg
3
- attr_accessor :number, :date, :departure, :arrival, :status
3
+ attr_accessor :number, :date, :departure, :arrival, :status, :progress
4
4
 
5
5
  def initialize(number, date, departure, arrival, status)
6
6
  self.number = number
@@ -8,10 +8,11 @@ module JetBluePlaneTracker
8
8
  self.departure = departure
9
9
  self.arrival = arrival
10
10
  self.status = status
11
+ self.progress = flight_tracker_progress
11
12
  end
12
13
 
13
14
  def to_s
14
- "##{number}\n#{departure}\n#{arrival}\n#{status}"
15
+ "##{number}\n#{departure}\n#{arrival}\n#{status}\n#{progress}"
15
16
  end
16
17
 
17
18
  def to_json
@@ -20,10 +21,29 @@ module JetBluePlaneTracker
20
21
  "date" => self.date,
21
22
  "departure" => self.departure.to_json,
22
23
  "arrival" => self.arrival.to_json,
23
- "status" => self.status
24
+ "status" => self.status,
25
+ "progress" => self.progress
24
26
  }.to_json
25
27
  end
26
28
 
29
+ def flight_tracker_progress
30
+ min_progress = 0
31
+ max_progress = 1
32
+ progress = 0
33
+
34
+ current_datetime = Time.now.to_i
35
+ actual_arrival = Time.parse(self.arrival.actual_takeoff).to_i
36
+ actual_departure = Time.parse(self.departure.actual_takeoff).to_i
37
+
38
+ progress = (current_datetime - actual_departure).to_f / (actual_arrival- actual_departure).to_f
39
+
40
+ progress = progress < min_progress ? min_progress : progress
41
+
42
+ progress = progress > max_progress ? max_progress : progress
43
+
44
+ progress * 100
45
+ end
46
+
27
47
  end
28
48
 
29
49
  end
@@ -1,3 +1,3 @@
1
1
  module JetBluePlaneTracker
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -6,4 +6,4 @@ require File.expand_path('../jetblue_plane_tracker/leg', __FILE__)
6
6
  require File.expand_path('../jetblue_plane_tracker/travel', __FILE__)
7
7
  require File.expand_path('../jetblue_plane_tracker/departure', __FILE__)
8
8
  require File.expand_path('../jetblue_plane_tracker/arrival', __FILE__)
9
- require File.expand_path('../jetblue_plane_tracker/tracker', __FILE__)
9
+ 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.0
4
+ version: 0.2.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-07-31 00:00:00.000000000 Z
11
+ date: 2015-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty