-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rb
More file actions
30 lines (22 loc) · 696 Bytes
/
Copy pathmain.rb
File metadata and controls
30 lines (22 loc) · 696 Bytes
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
require_relative "lib/input_validator"
require_relative "lib/command"
require_relative "lib/report"
InputValidator.validate_argument(ARGV)
site_map = File.read(ARGV[0]).split
site_map.map! { |row| row.split("") }
command = Command.new(site_map)
Report.display_welcome(site_map)
# Command input loop
while command.simulation_active
print "(l)eft, (r)ight, (a)dvance <n>, (m)ap, (q)uit: "
input = STDIN.gets.chomp
response = command.execute(input)
puts response[:error_description] if response[:error_raised?]
end
shutdown_data = response[:shutdown_data]
report = Report.new(
shutdown_data[:commands],
shutdown_data[:routes],
shutdown_data[:end_map]
)
report.display_summary()