Class: ITRP::Cmd_counter
Instance Attribute Summary
Attributes inherited from Cmd
#attach_cmd, #children, #enabled_in_state, #trigger
Instance Method Summary collapse
- #completions(patt) ⇒ Object
- #enter(cmdline) ⇒ Object
-
#initialize(e) ⇒ Cmd_counter
constructor
A new instance of Cmd_counter.
Methods inherited from Cmd
#appstate, #find_node, #is_root?, #place_node, #print_state, #set_time_window, #treeprint
Constructor Details
#initialize(e) ⇒ Cmd_counter
Returns a new instance of Cmd_counter.
4 5 6 7 8 9 |
# File 'lib/handlers/counter.rb', line 4 def initialize (e) super(e) @enabled_in_state = :any @attach_cmd = 'set' @trigger = 'counter' end |
Instance Method Details
#completions(patt) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/handlers/counter.rb', line 11 def completions(patt) req =mk_request(TRP::Message::Command::COUNTER_GROUP_INFO_REQUEST) cgdtls = [] get_response_zmq(@appenv.zmq_endpt,req) do |resp| resp.group_details.each do |group_detail| cgdtls << group_detail.name cgdtls << group_detail.guid end end cgdtls.grep( /^#{Regexp.escape(patt)}/i) end |
#enter(cmdline) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/handlers/counter.rb', line 27 def enter(cmdline) req =mk_request(TRP::Message::Command::COUNTER_GROUP_INFO_REQUEST) patt = cmdline.scan(/set\s+counter\s+(.*)/).flatten.first get_response_zmq(@appenv.zmq_endpt,req) do |resp| resp.group_details.each do |group_detail| if group_detail.name == patt print("\nContext set to counter group [#{group_detail.name}] [#{group_detail.guid}]\n\n") @appenv.prompt = "iTRP C:(#{patt})> " @appenv.context_data[:cgguid] = group_detail.guid @appenv.context_data[:cgname] = group_detail.name @appenv.context = :counter return end end end end |