Class: Controlio::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/controlio/client.rb

Constant Summary collapse

POLL_DELAY =
5

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



11
12
13
14
# File 'lib/controlio/client.rb', line 11

def initialize
  authorize
  generate_command_mappings!
end

Instance Method Details

#goObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/controlio/client.rb', line 16

def go
  loop do
    check_for_commands.each do |c|
      klass, args = command_options(c)
      if klass.present?
        puts "Running #{klass} (#{args})"
        instance = klass.new(args, @settings)
        spawn_and_timeout instance
      else
        send "Command '#{c['message']}' was not found!"
      end
      destroy c['_id']
    end
    sleep POLL_DELAY
  end
end