All pastes #49083 Raw Edit

Miscellany

public ruby v1 · immutable
#49083 ·published 2006-04-11 22:48 UTC
rendered paste body
class DirExt < Dir        def initialize (path)                @root = false                super.initialize(path)        end        def initialize (path, root)                @root = root                super.initialize(path)        end        def dirs                self.collect do |item|                        break if (item==".." && @root)                        path = d.path+"/"+item                        DirExt.new(path,false) if File.stat(path.directory?                end.compact        end        def files                self.collect do |item|                        path = d.path+"/"+item                        File.new(path) unless File.stat(path).directory?                end.compact        endend