Module: DirTravel
- Defined in:
- lib/dirtravel.rb,
lib/version.rb
Overview
DirTravel is a library for getting information about files and directories recursively to a tree structure. This library extends the RubyTree classes to include directory and files info. Please refer to RubyTree documentation for RubyTree related features.
A proxy object Travel is used to gather the directory content. The “filetree” class method provides interface for getting the content with few options (see: Travel.filetree for details).
See the Entry methods doc for possibilities in examining the directory hierachy.
Examples:
require 'dirtravel'
# Collect all entries under '.'
d = DirTravel::Travel.filetree( '.' )
# Display names of the entries in the hierarhcy.
d.children.each do |i|
puts i.name
end
# Display absolute path for file (leaf level) entries.
d.each_leaf do |i|
puts i.abspath
end
# Get MP3 files and create a list of all album directories.
# Assume: ".../<album>/<song>" hierarhcy
#
d = DirTravel::Travel.filetree( '.', { :suffix => '.mp3' } )
albums = d.select_level( d.node_height - 1 )
Defined Under Namespace
Classes: DirEntry, DirTravelError, Entry, FileEntry, Travel
Constant Summary collapse
- VERSION =
"0.0.7"