Class: RedisRing::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/redis_ring/cli.rb

Constant Summary collapse

COMMANDS =
[:help, :start]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



9
10
11
# File 'lib/redis_ring/cli.rb', line 9

def initialize(argv)
  @argv = argv
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



7
8
9
# File 'lib/redis_ring/cli.rb', line 7

def argv
  @argv
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/redis_ring/cli.rb', line 13

def run
  command = argv[0]
  if command.nil? || !COMMANDS.include?(command.to_sym)
    usage
    exit(1)
  else
    send(command, *argv[1..-1])
    exit(0)
  end
end