Class: ATCTools::FlightPlanValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/atc-tools/script/flight_plan_validator.rb

Overview

Script that extracts a flight plan from VRC.

Class Method Summary collapse

Class Method Details

.flight_planObject

The last flight plan returned.



11
12
13
# File 'lib/atc-tools/script/flight_plan_validator.rb', line 11

def self.flight_plan
  @flight_plan
end

.runObject

Note: Executing this script will call commands in the VRC client and will interfere with the user.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/atc-tools/script/flight_plan_validator.rb', line 17

def self.run
  vrc = ATCTools::VRC.new
  
  begin
    @flight_plan = vrc.selected_flight_plan!
  rescue ATCTools::NoAircraftSelectedError
    return 'No aircraft selected.'
  end
  
  vrc.activate_terminal_window!
  
  heading_thread = Thread.new do
    begin
      @flight_plan.heading
    rescue ATCTools::HeadingDiscoveryError
      Launchy.open @flight_plan.depart.heading_uri
    end
  end
  
  airport_name_thread = Thread.new do
    begin
      @flight_plan.arrive.name
    rescue ATCTools::NameDiscoveryError
      Launchy.open "https://www.google.com/#q=#{@flight_plan.arrive.code.to_s.upcase}+airport"
    end
  end
  
  heading_thread.join
  airport_name_thread.join
  
  output = []
  
  output << '------------------------------------------------------------'
  output << vrc.flight_plan_title
  output << ''
  output << @flight_plan.to_s.split("\n")
  output << ''
  output << ''
  output << "Alt Valid?  #{(@flight_plan.altitude_valid?) ? 'Yes' : '-NO-'}"
  output << "Heading:    #{@flight_plan.heading.round(2)} mag :: #{@flight_plan.depart.magnetic_to_true(@flight_plan.heading).round(2)} true"
  output << ''
  output << @flight_plan.aircraft.info.split(' - ').join("\n").strip
  output << '------------------------------------------------------------'
  
  text = output.join("\n")
end