Class: TrafficLightController::CLI

Inherits:
Object
  • Object
show all
Includes:
CommandLineHelper::HelpText
Defined in:
lib/traffic_light_controller/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



16
17
18
# File 'lib/traffic_light_controller/cli.rb', line 16

def initialize
  @server = Server.new
end

Class Method Details

.runObject



8
9
10
11
12
13
# File 'lib/traffic_light_controller/cli.rb', line 8

def run
  change_program_name
  cli = self.new
  cli.process_command_line_options
  cli.run
end

Instance Method Details

#process_command_line_optionsObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/traffic_light_controller/cli.rb', line 20

def process_command_line_options
  GetoptLong.new(*options_possible).each do |opt, arg|
    case opt
    when '--help'
      show_help_and_exit
    when '--version'
      show_version_info_and_exit
    end
  end
end

#runObject



31
32
33
# File 'lib/traffic_light_controller/cli.rb', line 31

def run
  server.work
end