Class: Mysh::SmartSource
- Defined in:
- lib/mysh/sources/smart_auto_complete.rb
Overview
An array as the source for auto-complete.
Instance Method Summary collapse
-
#initialize(options) ⇒ SmartSource
constructor
Create a new file/folder auto-data source.
-
#next ⇒ Object
Get the next string for auto-complete.
-
#rebuild(str) ⇒ Object
Construct a new data list for auto-complete.
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() @prefix = [:prefix] @auto_source = MiniReadline::AutoFileSource.new() @quote_source = MiniReadline::QuotedFileFolderSource.new() @active_source = nil end |
Instance Method Details
#next ⇒ Object
Get the next string for auto-complete
30 31 32 |
# File 'lib/mysh/sources/smart_auto_complete.rb', line 30 def next @active_source ? @active_source.next : @str end |
#rebuild(str) ⇒ Object
Construct a new data list for auto-complete
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mysh/sources/smart_auto_complete.rb', line 18 def rebuild(str) if /(?<=\s|^)\$[a-z][a-z0-9_]*\z/ =~ str sym = $MATCH[1..-1].to_sym @active_source = nil return @str = $PREMATCH + MNV[sym] if MNV.key?(sym) end @active_source = (@prefix || str[0]) == '=' ? @quote_source : @auto_source @active_source.rebuild(str) end |