class Zold::DirItems

Items in a dir

Public Class Methods

new(dir) click to toggle source
# File lib/zold/dir_items.rb, line 37
def initialize(dir)
  @dir = dir
end

Public Instance Methods

fetch(recursive: true) click to toggle source
# 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