Class: YapShellAddonTabCompletion::BasicCompletion

Inherits:
Object
  • Object
show all
Defined in:
lib/yap-shell-addon-tab-completion/basic_completion.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(world:, word_break_characters:, path: nil) ⇒ BasicCompletion

Returns a new instance of BasicCompletion.



10
11
12
13
14
15
# File 'lib/yap-shell-addon-tab-completion/basic_completion.rb', line 10

def initialize(world:, word_break_characters:, path:nil)
  @world = world
  @word_break_characters = word_break_characters
  path ||= @world.env["PATH"]
  @paths = path.split(":")
end

Class Attribute Details

.priorityObject

Returns the value of attribute priority.



4
5
6
# File 'lib/yap-shell-addon-tab-completion/basic_completion.rb', line 4

def priority
  @priority
end

Instance Attribute Details

#worldObject (readonly)

Returns the value of attribute world.



8
9
10
# File 'lib/yap-shell-addon-tab-completion/basic_completion.rb', line 8

def world
  @world
end

Instance Method Details

#completions_for(word, words, word_index) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/yap-shell-addon-tab-completion/basic_completion.rb', line 17

def completions_for(word, words, word_index)
  completions_by_name = {}
  if looking_for_command?(word, words, word_index)
    # Lowest Priority
    completions_by_name.merge! command_completion_matches_for(word, words)

    # Low Priority
    completions_by_name.merge! builtin_completion_matches_for(word, words)

    # Medium Priority
    completions_by_name.merge! executable_filename_completion_matches_for(word, words)

    # High Priority
    completions_by_name.merge! shell_command_completion_matches_for(word, words)

    # Highest Priority
    completions_by_name.merge! alias_completion_matches_for(word, words)
  else
    completions_by_name.merge! filename_completion_matches_for(word, words)
  end
  completions_by_name.merge! environment_variable_completions_for(word, words)
  completions_by_name.values
end