Class: Smith::Commands::ObjectCount

Inherits:
Smith::CommandBase show all
Defined in:
lib/smith/commands/agency/object_count.rb

Instance Attribute Summary

Attributes inherited from Smith::CommandBase

#options, #target

Instance Method Summary collapse

Methods inherited from Smith::CommandBase

#banner, #format_help, #initialize, #parse_options

Methods included from Logger

included

Constructor Details

This class inherits a constructor from Smith::CommandBase

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/smith/commands/agency/object_count.rb', line 10

def execute
  if target.size > 1
    responder.succeed("You can only specify one agent at at time.")
  else
    agent = agents[target.first]
    if agent.running?

      # object_count(agent) do |objects|
      #   responder.succeed(objects)
      # end

      object_count(agent)
      responder.succeed('') #(objects)
    else
      responder.succeed("Agent not running: #{target.first}")
    end
  end
end

#object_count(agent) ⇒ Object

, &blk)



29
30
31
32
33
34
# File 'lib/smith/commands/agency/object_count.rb', line 29

def object_count(agent) #, &blk)
  Messaging::Sender.new(agent.control_queue_def) do |sender|
    # sender.on_reply(blk)
    sender.publish(ACL::AgentCommand.new(:command => 'object_count', :options => [options[:threshold].to_s]))
  end
end