Class: Runner
Instance Method Summary
collapse
Methods included from UserInput
#classes, #define_class_to_group, #define_cli_flags, #define_groups, #define_letter_to_class, #l_flag, #look_up_class_group, #look_up_letter_class, #print_options, #prompt
Constructor Details
#initialize(params = nil) ⇒ Runner
Returns a new instance of Runner.
8
9
10
11
12
13
|
# File 'lib/uss-enterprise.rb', line 8
def initialize(params = nil)
@params = params
@flags = self.define_cli_flags
@letter_to_class = self.define_letter_to_class
@class_to_group = self.define_class_to_group
end
|
Instance Method Details
#build_ship(s_group, s_class) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/uss-enterprise.rb', line 15
def build_ship(s_group, s_class)
ship = ShipChooser.new
ship.choose_ship_group(s_group)
ship.choose_ship_class(s_class)
ship.commission_construction
end
|
#gently_correct_usage ⇒ Object
36
37
38
39
40
41
|
# File 'lib/uss-enterprise.rb', line 36
def gently_correct_usage
puts "For a random Enterprise, supply no arguments or flags. If you want to specify a ship, use the '-l' flag followed by one of the following arguments:\n\n"
@letter_to_class.each do |arg, output|
puts "\t#{arg} \t=> \t#{output}"
end
end
|
#handle_args ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/uss-enterprise.rb', line 22
def handle_args
begin
if @params.length == 0
self.build_ship('random', 'random')
elsif @params.include? '-l'
self.l_flag
else
self.gently_correct_usage
end
rescue
self.gently_correct_usage
end
end
|