Class: FileTree
Constant Summary collapse
- @@files =
[]
- @@root_id =
nil
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.add(files) ⇒ Object
27 28 29 30 |
# File 'lib/dynalist/file_tree.rb', line 27 def self.add(files) @@files << files @@files.flatten! end |
.clear ⇒ Object
23 24 25 |
# File 'lib/dynalist/file_tree.rb', line 23 def self.clear @@files = [] end |
.find_by(**query) ⇒ Object
32 33 34 |
# File 'lib/dynalist/file_tree.rb', line 32 def self.find_by(**query) @@files.find { |file| file.include(**query) } end |
.where(**query) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dynalist/file_tree.rb', line 36 def self.where(**query) @@files.select do |file| query.all? do |key, value| if value.kind_of? Array value.any? { |v| file.include(**{key => v}) } else file.include(**{key => value}) end end end end |
Instance Method Details
#files ⇒ Object
19 20 21 |
# File 'lib/dynalist/file_tree.rb', line 19 def files @@files end |
#root_id ⇒ Object
15 16 17 |
# File 'lib/dynalist/file_tree.rb', line 15 def root_id @@root_id end |
#root_id=(root_id) ⇒ Object
11 12 13 |
# File 'lib/dynalist/file_tree.rb', line 11 def root_id=(root_id) @@root_id = root_id end |