Class: ForemanMaintain::Utils::Bash::Completion
- Inherits:
-
Object
- Object
- ForemanMaintain::Utils::Bash::Completion
- Defined in:
- lib/foreman_maintain/utils/bash.rb
Class Method Summary collapse
Instance Method Summary collapse
- #complete(line) ⇒ Object
-
#initialize(dict) ⇒ Completion
constructor
A new instance of Completion.
Constructor Details
#initialize(dict) ⇒ Completion
Returns a new instance of Completion.
7 8 9 |
# File 'lib/foreman_maintain/utils/bash.rb', line 7 def initialize(dict) @dict = dict end |
Class Method Details
.load_description(path) ⇒ Object
23 24 25 26 27 |
# File 'lib/foreman_maintain/utils/bash.rb', line 23 def self.load_description(path) YAML.load(File.open(path)) rescue Errno::ENOENT {} end |
Instance Method Details
#complete(line) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/foreman_maintain/utils/bash.rb', line 11 def complete(line) @complete_line = line.end_with?(' ') full_path = line.split(' ') complete_path = @complete_line ? full_path : full_path[0..-2] dict, path = traverse_tree(@dict, complete_path) return [] unless path.empty? # lost during traversing partial = @complete_line ? '' : full_path.last finish_word(dict, partial) end |