Method: Dispatches#initialize
- Defined in:
- lib/itrp.rb
#initialize ⇒ Dispatches
Returns a new instance of Dispatches.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/itrp.rb', line 46 def initialize() # load handlers reload # root proc @cmd_roots = { :any => ITRP::Cmd_root.new(Appenv) } @cmd_roots[:any].set_time_window # build command tree (ITRP::constants-[:Cmd, :Cmd_root]).each do |k| kls = ITRP::const_get(k) ins = kls.new(Appenv) @cmd_roots[ins.enabled_in_state] ||= ITRP::Cmd_root.new(Appenv) @cmd_roots[ins.enabled_in_state].place_node(ins) end # hook up autocompletion Readline.completion_proc = proc do |s| buff = Readline.line_buffer() [Appenv.context, :any].uniq.collect do |ctx| node = @cmd_roots[ctx].find_node(buff.split(' ')) (node or @cmd_roots[:any]).completions(s) end.flatten end # history load if File.exist? HISTFILE File.readlines(HISTFILE).each do |l| Readline::HISTORY.push(l.chop) end end end |