Class: AutoComplete

Inherits:
Object
  • Object
show all
Defined in:
lib/old/autocomplete.rb

Overview

part of autocompletion

Instance Method Summary collapse

Constructor Details

#initializeAutoComplete

Returns a new instance of AutoComplete.



9
10
11
# File 'lib/old/autocomplete.rb', line 9

def initialize
  @commands = ["build", "buck", "monkey"].sort
end

Instance Method Details

#interpret(arg_frag) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/old/autocomplete.rb', line 12

def interpret(arg_frag)
  ret = []
  @commands.each do |com|
    ret << com if com.to_s.match arg_frag # only if it matches
    # TODO break if we're after it
  end

  if ret.length > 1 # if we found multiple matches
    raise Hell, "Too ambiguous of a command" # raise Hell
  else # else its size = 1
    return ret[0] # return the symbol
  end
end