Class: TabTab::Completions::File
- Inherits:
-
Object
- Object
- TabTab::Completions::File
- Defined in:
- lib/tabtab/completions/file.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#current_token ⇒ Object
readonly
Returns the value of attribute current_token.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#global_config ⇒ Object
readonly
Returns the value of attribute global_config.
-
#previous_token ⇒ Object
readonly
Returns the value of attribute previous_token.
Instance Method Summary collapse
-
#extract ⇒ Object
Returns the sub-list of all options filtered by a common prefix e.g.
-
#initialize(file_path, app_name, current_token, previous_token, global_config = {}) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(file_path, app_name, current_token, previous_token, global_config = {}) ⇒ File
Returns a new instance of File.
4 5 6 7 8 9 10 |
# File 'lib/tabtab/completions/file.rb', line 4 def initialize(file_path, app_name, current_token, previous_token, global_config = {}) @file_path = file_path @app_name = app_name @current_token = current_token @previous_token = previous_token @global_config = global_config end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
2 3 4 |
# File 'lib/tabtab/completions/file.rb', line 2 def app_name @app_name end |
#current_token ⇒ Object (readonly)
Returns the value of attribute current_token.
2 3 4 |
# File 'lib/tabtab/completions/file.rb', line 2 def current_token @current_token end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
2 3 4 |
# File 'lib/tabtab/completions/file.rb', line 2 def file_path @file_path end |
#global_config ⇒ Object (readonly)
Returns the value of attribute global_config.
2 3 4 |
# File 'lib/tabtab/completions/file.rb', line 2 def global_config @global_config end |
#previous_token ⇒ Object (readonly)
Returns the value of attribute previous_token.
2 3 4 |
# File 'lib/tabtab/completions/file.rb', line 2 def previous_token @previous_token end |
Instance Method Details
#extract ⇒ Object
Returns the sub-list of all options filtered by a common prefix e.g. if current extract
list is [‘–help’, ‘–extra’, ‘-h’, ‘-x’] then starts_with(‘–’) returns [‘–help’, ‘–extra’]
15 16 17 18 19 20 21 22 |
# File 'lib/tabtab/completions/file.rb', line 15 def extract if File.exists?(file_path) load file_path TabTab::Definition[app_name].extract_completions(previous_token, current_token, global_config) else [] end end |