Class: Bombshell::Completor
- Inherits:
-
Object
- Object
- Bombshell::Completor
- Defined in:
- lib/bombshell/completor.rb
Overview
A class used by IRB.start_session
to handle tab completion.
Instance Attribute Summary collapse
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
Class Method Summary collapse
-
.filter(m) ⇒ Object
Filter out irrelevant methods that shouldn’t appear in a completion list.
Instance Method Summary collapse
-
#complete(fragment) ⇒ Object
Provide completion for a given fragment.
-
#initialize(shell) ⇒ Completor
constructor
Always initialize Completor with the shell it’s completing for.
Constructor Details
#initialize(shell) ⇒ Completor
Always initialize Completor with the shell it’s completing for.
5 6 7 |
# File 'lib/bombshell/completor.rb', line 5 def initialize(shell) @shell = shell end |
Instance Attribute Details
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
9 10 11 |
# File 'lib/bombshell/completor.rb', line 9 def shell @shell end |
Class Method Details
Instance Method Details
#complete(fragment) ⇒ Object
Provide completion for a given fragment.
13 14 15 |
# File 'lib/bombshell/completor.rb', line 13 def complete(fragment) self.class.filter(shell.instance_methods).grep Regexp.new(Regexp.quote(fragment)) end |