Class: FileSelector
- Inherits:
-
Object
- Object
- FileSelector
- Defined in:
- lib/file_selector.rb
Class Method Summary collapse
Instance Method Summary collapse
- #explore ⇒ Object
- #explore_mode(path = Dir.pwd) ⇒ Object
-
#initialize ⇒ FileSelector
constructor
A new instance of FileSelector.
Constructor Details
#initialize ⇒ FileSelector
Returns a new instance of FileSelector.
9 10 11 12 |
# File 'lib/file_selector.rb', line 9 def initialize @files = Set[] @prompt = TTY::Prompt.new end |
Class Method Details
.explore ⇒ Object
5 6 7 |
# File 'lib/file_selector.rb', line 5 def self.explore new.explore end |
Instance Method Details
#explore ⇒ Object
14 15 16 17 |
# File 'lib/file_selector.rb', line 14 def explore explore_mode @files end |
#explore_mode(path = Dir.pwd) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/file_selector.rb', line 19 def explore_mode(path = Dir.pwd) system 'clear' files = files_in path = ['finish', 'include', File.dirname(path)] + files prompt = 'Files and directoies to explore', choice = @prompt.select(prompt, , per_page: 20) if choice == 'include' include_mode(path) explore_mode(path) elsif choice != 'finish' if File.directory?(choice) explore_mode(choice) if File.directory?(choice) else system "less #{choice}" unless File.directory?(choice) explore_mode(path) end end end |