Class: MiniReadline::QuotedFileFolderSource
- Inherits:
-
Object
- Object
- MiniReadline::QuotedFileFolderSource
- Defined in:
- lib/mini_readline/read_line/edit/auto_complete/quoted_file_folder_source.rb
Overview
The data source for auto-complete.
Constant Summary collapse
- REGEX =
The parsing regular expression.
/(?<=\")([^\"\s][^\"]*)?(?=\"?$)/
Instance Method Summary collapse
-
#extract_root_pivot(str) ⇒ Object
Parse the string into the two basic components.
-
#initialize(_options) ⇒ QuotedFileFolderSource
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) ⇒ QuotedFileFolderSource
Create a new file/folder auto-data source. NOP
10 |
# File 'lib/mini_readline/read_line/edit/auto_complete/quoted_file_folder_source.rb', line 10 def initialize(); end |
Instance Method Details
#extract_root_pivot(str) ⇒ Object
Parse the string into the two basic components.
25 26 27 |
# File 'lib/mini_readline/read_line/edit/auto_complete/quoted_file_folder_source.rb', line 25 def extract_root_pivot(str) @root, @pivot = REGEX =~ str ? [$PREMATCH, $MATCH] : [str + '"', ""] end |
#next ⇒ Object
Get the next string for auto-complete
30 31 32 |
# File 'lib/mini_readline/read_line/edit/auto_complete/quoted_file_folder_source.rb', line 30 def next "#{@root}#{@cycler.next}\"" end |
#rebuild(str) ⇒ Object
Construct a new data list for auto-complete
13 14 15 16 17 18 19 |
# File 'lib/mini_readline/read_line/edit/auto_complete/quoted_file_folder_source.rb', line 13 def rebuild(str) extract_root_pivot(str) list = Dir.glob(@pivot + '*') @cycler = list.empty? ? nil : list.cycle end |