Class: RubyGrep::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-grep/directory.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Directory

Returns a new instance of Directory.



5
6
7
# File 'lib/ruby-grep/directory.rb', line 5

def initialize(path)
  @path = path
end

Instance Method Details

#filesObject

this method finds all entries in the @path (directory) including all in all sudirectories of the given @path and returns them as an array of elements of type RubyGrep::File



11
12
13
14
# File 'lib/ruby-grep/directory.rb', line 11

def files
  @files ||= Dir.glob(::File.join("#{@path}", "**", "{*,.*}")).select { |f| ::File.file?(f) }.
  map { |file_name| RubyGrep::File.new("#{file_name}") }
end