Class: Stowaway::Locator
- Inherits:
-
Object
- Object
- Stowaway::Locator
- Includes:
- FSHelpyHelp
- Defined in:
- lib/stowaway/locator.rb
Instance Method Summary collapse
- #find_all(path, files = []) ⇒ Object
-
#initialize(extensions) ⇒ Locator
constructor
A new instance of Locator.
- #type?(file) ⇒ Boolean
Methods included from FSHelpyHelp
Constructor Details
#initialize(extensions) ⇒ Locator
Returns a new instance of Locator.
8 9 10 11 |
# File 'lib/stowaway/locator.rb', line 8 def initialize(extensions) @extensions = extensions @ignore = [/^\./] end |
Instance Method Details
#find_all(path, files = []) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/stowaway/locator.rb', line 13 def find_all(path, files = []) @root = path if @root.nil? dir = Dir.new(path) dir.each do |f| next if ignore?(f) file = File.join(dir.path, f) if File.directory?(file) find_all file, files elsif type?(f) files << FileObj.new(file, @root) end end files end |
#type?(file) ⇒ Boolean
32 33 34 35 36 37 |
# File 'lib/stowaway/locator.rb', line 32 def type?(file) @extensions.each do |e| return true if file.match(/#{e}$/) end false end |