Class: Zold::DirItems
- Inherits:
-
Object
- Object
- Zold::DirItems
- Defined in:
- lib/zold/dir_items.rb
Overview
Items in a dir
Instance Method Summary collapse
- #fetch(recursive: true) ⇒ Object
-
#initialize(dir) ⇒ DirItems
constructor
A new instance of DirItems.
Constructor Details
#initialize(dir) ⇒ DirItems
Returns a new instance of DirItems.
37 38 39 |
# File 'lib/zold/dir_items.rb', line 37 def initialize(dir) @dir = dir end |
Instance Method Details
#fetch(recursive: true) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/zold/dir_items.rb', line 41 def fetch(recursive: true) `find #{([@dir] + (recursive ? [] : ['-maxdepth', '1']) + ['-type', 'f', '-print']).join(' ')} 2>/dev/null` .strip .split .select { |f| f.start_with?(@dir) && f.length > @dir.length } .map { |f| f[(@dir.length + 1)..-1] } end |