Class: SourceFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/source_files.rb

Overview

class SourceFiles

A simple class to assist collect all files or some files in a directory.

Class Method Summary collapse

Class Method Details

.get_all(dir, &block) ⇒ Object



6
7
8
9
10
# File 'lib/source_files.rb', line 6

def get_all(dir, &block)
  @files = []
  get_all_helper(dir, &block)
  @files
end

.get_in(dir) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/source_files.rb', line 12

def get_in(dir)
  @files = []
  Dir.each_child(dir) do |f|
    file = "#{dir}/#{f}"
    next unless File.file?(file)

    add = true
    add = yield(f) if block_given?
    @files << file.to_s if add
  end

  @files
end