Sha256: 80100f682e73189ea839b0ed032d7c235b4970bb4b2723e5dd5058e79223ed49

Contents?: true

Size: 600 Bytes

Versions: 9

Compression:

Stored size: 600 Bytes

Contents


require 'fileutils'


class FileSystem
  include FileUtils

  attr_reader :root

  def initialize( )
    @root = "/"
  end

  def root?(dir=nil)
    pth = File.expand_path(dir||work)
    return true if pth == '/'
    return true if pth =~ /^(\w:)?\/$/
    false
  end 

  def work; Dir.pwd; end

  def ls
    Dir.entries.collect do |f|
      File.directory?(f) ? Dir.new(f) : File.new(f) 
    end
  end

  # Direct access to a directory or file.

  def [](name)
    if File.directory?(name)
      Dir.new(name)
    elsif File.file?(name)
      File.new(name)
    else
      nil
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
facets-1.7.38 lib/facets/more/filesystem.rb
facets-1.7.30 lib/facets/more/filesystem.rb
facets-1.7.46 lib/facets/more/filesystem.rb
facets-1.8.51 lib/facets/more/filesystem.rb
facets-1.8.20 lib/facets/more/filesystem.rb
facets-1.8.49 lib/facets/more/filesystem.rb
facets-1.8.0 lib/facets/more/filesystem.rb
facets-1.8.8 lib/facets/more/filesystem.rb
facets-1.8.54 lib/facets/more/filesystem.rb