class Bombshell::Completor

A class used by IRB.start_session to handle tab completion.

Attributes

shell[R]

Public Class Methods

filter(m) click to toggle source

Filter out irrelevant methods that shouldn’t appear in a completion list.

# File lib/bombshell/completor.rb, line 18
def self.filter(m)
  (m - Bombshell::Environment.instance_methods - Bombshell::Shell::Commands::HIDE).reject do |m|
    m =~ /^_/
  end
end
new(shell) click to toggle source

Always initialize Completor with the shell it’s completing for.

# File lib/bombshell/completor.rb, line 5
def initialize(shell)
  @shell = shell
end

Public Instance Methods

complete(fragment) click to toggle source

Provide completion for a given fragment. @param [String] fragment the fragment to complete for

# File lib/bombshell/completor.rb, line 13
def complete(fragment)
  self.class.filter(shell.instance_methods).grep Regexp.new(Regexp.quote(fragment))
end