Class: ITRP::Cmd_grep
Instance Attribute Summary
Attributes inherited from Cmd
#attach_cmd, #children, #enabled_in_state, #trigger
Instance Method Summary collapse
- #enter(cmdline) ⇒ Object
-
#initialize(e) ⇒ Cmd_grep
constructor
A new instance of Cmd_grep.
Methods inherited from Cmd
#appstate, #completions, #find_node, #is_root?, #place_node, #print_state, #set_time_window, #treeprint
Constructor Details
#initialize(e) ⇒ Cmd_grep
Returns a new instance of Cmd_grep.
4 5 6 7 8 9 |
# File 'lib/handlers/grep.rb', line 4 def initialize (e) super(e) @enabled_in_state = :any @attach_cmd = '' @trigger = 'grep' end |
Instance Method Details
#enter(cmdline) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/handlers/grep.rb', line 11 def enter(cmdline) patt = cmdline.scan(/grep\s+(\w+)/).flatten.first req =TrisulRP::Protocol.mk_request(TRP::Message::Command::GREP_REQUEST, :time_interval => appstate(:time_interval), :pattern_text => patt ) rows = [] TrisulRP::Protocol.get_response_zmq(@appenv.zmq_endpt,req) do |resp| sz = resp.sessions.size (0..sz-1).each do |i| s = resp.sessions[i] rows << [ s.session_key, s.time_interval.from.tv_sec, s.time_interval.to.tv_sec, s.key1A.label, s.key1Z.label, resp.hints[i]] end end table = Terminal::Table.new( :headings => %w(key tmFrom tmTo IPA IPZ hints ), :rows => rows) puts(table) if cmdline =~ /savefilter/ fkeys = rows.collect{ |r| r[0] }.join(",") @appenv.context_data[:filter] = '{99A78737-4B41-4387-8F31-8077DB917336}=' + fkeys puts "Filter string saved as @appenv.context_data[:filter] " + @appenv.context_data[:filter] end end |