Class: Zephira::Completions

Inherits:
Object
  • Object
show all
Defined in:
lib/zephira/completions.rb,
lib/zephira/completions/file_names.rb,
lib/zephira/completions/slash_commands.rb

Defined Under Namespace

Classes: FileNames, SlashCommands

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load(paths:) ⇒ Object



5
6
7
8
9
10
# File 'lib/zephira/completions.rb', line 5

def self.load(paths:)
  paths.each do |path|
    Dir.glob(File.join(path, "**", "*.rb")).each { |file| require file }
  end
  new
end

Instance Method Details

#complete_all(input:, agent:) ⇒ Object



18
19
20
# File 'lib/zephira/completions.rb', line 18

def complete_all(input:, agent:)
  constants.flat_map { |completion| completion.complete(input: input, agent: agent) }.uniq
end

#constantsObject



12
13
14
15
16
# File 'lib/zephira/completions.rb', line 12

def constants
  @constants ||= ::Zephira::Completions.constants(false).map do |name|
    ::Zephira::Completions.const_get(name)
  end
end