Class: Wemux::Pair::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/wemux/pair/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param) ⇒ Runner

Returns a new instance of Runner.



21
22
23
# File 'lib/wemux/pair/runner.rb', line 21

def initialize(param)
  @param = param.to_s.strip
end

Instance Attribute Details

#paramObject (readonly)

Returns the value of attribute param.



20
21
22
# File 'lib/wemux/pair/runner.rb', line 20

def param
  @param
end

Class Method Details

.run(params) ⇒ Object



16
17
18
# File 'lib/wemux/pair/runner.rb', line 16

def self.run(params)
  new(params).execute
end

Instance Method Details

#executeObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/wemux/pair/runner.rb', line 25

def execute
  case param
  when "host"
    Commands::CheckForPairUser.run(pair_user: Wemux::Pair.config.pair_user)
    Commands::CheckForWemux.run
    Commands::StartHostSession.run
  when "stop"
    Commands::StopSession.run
  when ->(param) { param.to_i > 0 }
    port_offset = param.to_i
    Commands::SetPowHost.run(
      pow_host: Wemux::Pair.config.pow_host,
      server_port: port_offset + 3000)
    Commands::StartClientSession.run(port_offset: port_offset)
  when "--init"
    Commands::CreateSampleConfig.run
  else
    Commands::PrintUsage.run
  end
end