Class: Kward::PromptInterface::ProjectFileTree
- Inherits:
-
Object
- Object
- Kward::PromptInterface::ProjectFileTree
- Defined in:
- lib/kward/prompt_interface/project_file_tree.rb
Overview
The filesystem-independent tree shared by /files and the editor Explorer.
Instance Method Summary collapse
-
#initialize(paths, directories: []) ⇒ ProjectFileTree
constructor
A new instance of ProjectFileTree.
- #rows(expanded) ⇒ Object
Constructor Details
#initialize(paths, directories: []) ⇒ ProjectFileTree
Returns a new instance of ProjectFileTree.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/kward/prompt_interface/project_file_tree.rb', line 7 def initialize(paths, directories: []) @directories = Hash.new { |hash, key| hash[key] = Set.new } @files = Hash.new { |hash, key| hash[key] = [] } directories.each { |path| add_directories(path.split("/")) } paths.each do |path| parent = add_directories(path.split("/")[0...-1]) @files[parent] << path end @directories.transform_values! { |children| children.to_a.sort } @files.each_value(&:sort!) end |
Instance Method Details
#rows(expanded) ⇒ Object
19 20 21 |
# File 'lib/kward/prompt_interface/project_file_tree.rb', line 19 def rows() append_rows([], "", , 0) end |