-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.rb
64 lines (54 loc) · 1.47 KB
/
cli.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
require "pry"
class UsAircraft::CLI
def call
puts "\nTop US Attack Aircraft.\n"
main_menu
end
def user_input
user_input = gets.strip
end
def sleep_counter
sleep(1.0)
puts "."
sleep(1.0)
puts ".."
sleep(1.0)
end
def main_menu
puts "Type 'list' to see aircraft or 'exit' to exit program."
case user_input
when 'list'
puts "Sure thing, loading database."
# sleep_counter
list_aircraft
when 'exit', 'quit'
goodbye
else
puts "Not a valid option. No surrender ! Try again !"
main_menu
end
end
def goodbye
puts "Goodbye! Have a nice day!"
end
def list_aircraft
puts "Lighting speeds, hundreds of succesful missions, the greatest US Attack Aircraft to date."
UsAircraft::Scraper.scrape_aircraft
@aircraft = UsAircraft::Aircraft.all
@aircraft.each.with_index(1) do |aircraft, index|
puts "#{index}. #{aircraft.name}"
end
get_more_info_for_aircraft
end
def get_more_info_for_aircraft
aircraft = gets.strip.to_i #sintrg to an integer to_i
UsAircraft::Scraper.more_info_for_aircraft(aircraft)
puts "AIRCRAFT INTEL FOR #{aircraft}."
UsAircraft::Aircraft.all.each.with_index(1) do |aircraft|
puts "#{aircraft.contractor} - #{aircraft.service} - #{aircraft.armament} - #{aircraft.power_plant} - #{aircraft.speed} - #{aircraft.range}"
end
end
def valid_input(input, data)
input.to_i <= data.length && input.to_i > 0
end
end