Class: OOFile::DirEntry
Overview
I represent directories in the filesystem.
Instance Attribute Summary
Attributes inherited from FsEntry
Instance Method Summary collapse
-
#files ⇒ Object
I return the files immediately in my directory.
-
#traverse(traverser) ⇒ Object
I am visitable with a Traverser.
Methods inherited from FsEntry
#==, #basename, #ctime, #dirname, #extname, #extnless, #from, from, #initialize, #inspect, #mtime, #size
Constructor Details
This class inherits a constructor from OOFile::FsEntry
Instance Method Details
#files ⇒ Object
I return the files immediately in my directory.
89 90 91 |
# File 'lib/oofile/filesystem.rb', line 89 def files (Dir.new(@path).entries.select {|entry| File.file?(File.join(@path,entry))}).map {|filepath| FsEntry.from(File.join(@path,filepath)) } end |
#traverse(traverser) ⇒ Object
I am visitable with a Traverser. I perform inorder traversal of FsEntries.
94 95 96 97 98 99 |
# File 'lib/oofile/filesystem.rb', line 94 def traverse(traverser) traverser.traverse_dir(self) Dir.new(@path).each do |stringpath| from(stringpath).traverse(traverser) unless stringpath=='.' || stringpath=='..' end end |