Class: Mysh::SmartSource

Inherits:
Object show all
Defined in:
lib/mysh/sources/smart_auto_complete.rb

Overview

  • array_source.rb - An array as the source for auto-complete.

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ SmartSource

Create a new file/folder auto-data source. NOP



10
11
12
13
14
15
# File 'lib/mysh/sources/smart_auto_complete.rb', line 10

def initialize(options)
  @prefix        = options[:prefix]
  @auto_source   = MiniReadline::AutoFileSource.new(options)
  @quote_source  = MiniReadline::QuotedFileFolderSource.new(options)
  @active_source = nil
end

Instance Method Details

#nextObject

Get the next string for auto-complete



24
25
26
# File 'lib/mysh/sources/smart_auto_complete.rb', line 24

def next
  @active_source.next
end

#rebuild(str) ⇒ Object

Construct a new data list for auto-complete



18
19
20
21
# File 'lib/mysh/sources/smart_auto_complete.rb', line 18

def rebuild(str)
  @active_source = (@prefix || str[0]) == '=' ? @quote_source : @auto_source
  @active_source.rebuild(str)
end