Class: Fast::DirFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/fast/dir-filter.rb

Overview

Specific filter for Dir entries. Should inherit or invoke a Generic Filter Just a stub for the moment

Instance Method Summary collapse

Constructor Details

#initialize(set) ⇒ DirFilter

Returns a new instance of DirFilter.



5
6
7
# File 'lib/fast/dir-filter.rb', line 5

def initialize set
  @set = set
end

Instance Method Details

#extension(the_extension) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/fast/dir-filter.rb', line 9

def extension the_extension
  return_me = Dir.new
  @set.each do |entry|
    return_me << entry if entry.end_with? the_extension
  end
  return_me
end

#match(regexp) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/fast/dir-filter.rb', line 25

def match regexp
  return_me = Dir.new
  @set.each do |entry|
    return_me << entry if entry.match regexp
  end
  return_me
end

#strip_extensionObject



17
18
19
20
21
22
23
# File 'lib/fast/dir-filter.rb', line 17

def strip_extension
  return_me = Dir.new
  @set.each do |entry|
    return_me.push entry.gsub /\.(\w+?)$/, ""
  end
  return_me
end