flightcheck 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flightcheck.rb +19 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbfa56f5f5ca4bebdf773149bf1edd814ef7d8a9
|
4
|
+
data.tar.gz: 67e026af7d2be2bf8bf48b4cadbd78f6a868fdb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 068f20236d1af6dd2f4a8b119c1e38c71b9ede8429fff361e75e71a9e02faacf628d1c714b4c4c2cfed88647169680923e9962235da35510b4b5aa821b34ac48
|
7
|
+
data.tar.gz: 1ebd6f353e453390587a00e81db9af48009a3bf6111ae972f79abc2b2ef4c2f38accdc872fd0b508b7557ca2de8d64022b679d557279c63dffe64d5c3def45b6
|
data/lib/flightcheck.rb
CHANGED
@@ -32,11 +32,14 @@ class Flight
|
|
32
32
|
# Returns a boolean value
|
33
33
|
@multiple_segments = page.search("//*[@id='mainAreaLeftColumn']/div/div/text()").text.strip === "This flight has multiple segments. Please select a segment from the list." ? true : false
|
34
34
|
|
35
|
+
# If there are multiple segments, ask the user to select the correct one
|
35
36
|
if @multiple_segments == true
|
36
37
|
|
38
|
+
# Extract segment information into the correct variables
|
37
39
|
@segment_1 = page.search("//*[@id='mainAreaLeftColumn']/div/div/p[1]/a").text.strip
|
38
40
|
@segment_2 = page.search("//*[@id='mainAreaLeftColumn']/div/div/p[2]/a").text.strip
|
39
41
|
|
42
|
+
# Ask the user to select the correct flight segment
|
40
43
|
puts "This flight has two flight segments,"
|
41
44
|
puts "please select the correct one"
|
42
45
|
puts "========================================"
|
@@ -46,6 +49,7 @@ class Flight
|
|
46
49
|
print "1 or 2? Make your choice: "
|
47
50
|
@selected_segment = gets.chomp
|
48
51
|
|
52
|
+
# Based on user input, get the flight information
|
49
53
|
if @selected_segment == "1"
|
50
54
|
@segment_1 = page.links[0].click
|
51
55
|
|
@@ -61,6 +65,7 @@ class Flight
|
|
61
65
|
# e.g. "(VCE) Venice, IT to (LGW) London, EN, GB"
|
62
66
|
@route = @segment_1.search("#mainAreaLeftColumn > div.uiComponent674.flightStatusByFlightBlock > div > div.route").text.strip
|
63
67
|
|
68
|
+
# Based on user input, get the flight information
|
64
69
|
elsif @selected_segment == "2"
|
65
70
|
@segment_2 = page.links[1].click
|
66
71
|
|
@@ -79,6 +84,20 @@ class Flight
|
|
79
84
|
else
|
80
85
|
puts "The input was unknown. Please use '1' for segment 1 and '2' for segment 2"
|
81
86
|
end
|
87
|
+
|
88
|
+
# When the flight has a single segment, fetch the information
|
89
|
+
else
|
90
|
+
# Page title contains the basic information for the flight
|
91
|
+
# e.g. "(BA) British Airways 2589 Flight Status"
|
92
|
+
@title = page.search("head > title").text.strip
|
93
|
+
|
94
|
+
# Flight status
|
95
|
+
# e.g. "Landed - Delayed 103 minutes"
|
96
|
+
@status = page.search("#mainAreaLeftColumn > div.uiComponent674.flightStatusByFlightBlock > div > div.statusBlock > div.statusType").text.strip
|
97
|
+
|
98
|
+
# Flight route
|
99
|
+
# e.g. "(VCE) Venice, IT to (LGW) London, EN, GB"
|
100
|
+
@route = page.search("#mainAreaLeftColumn > div.uiComponent674.flightStatusByFlightBlock > div > div.route").text.strip
|
82
101
|
end
|
83
102
|
end
|
84
103
|
|