class ProxyFS::FS

Attributes

dir[R]
file[R]

Public Class Methods

fs() click to toggle source
# File lib/proxyfs.rb, line 88
def self.fs
  @@fs
end
new(tree) click to toggle source
# File lib/proxyfs.rb, line 81
def initialize tree
  @tree = tree
  iam = self

  @dir = Class.new Dir do
    @@fs = iam

    def self.fs
      @@fs
    end

    def fs
      @@fs
    end
  end

  @file = Class.new File do
    @@fs = iam

    def self.fs
      @@fs
    end

    def fs
      @@fs
    end
  end
end

Public Instance Methods

entry(path) click to toggle source
# File lib/proxyfs.rb, line 110
def entry path
  path = Pathname.new path

  raise ArgumentError, 'path shall be absolute' unless path.absolute?

  patha = path.each_filename.to_a

  find = Proc.new do |patha, curdir|
    name = patha[0]
    raise Errno::ENOENT unless curdir.include? name

    e = curdir[name]

    rest_patha = patha[1..(-1)]

    if rest_patha.empty?
      e
    else
      if Hash === e
        find[rest_patha, e]
      elsif Array === e
        find[rest_patha, e[0].new(*e[1..(-1)])]
      else
        find[rest_patha, e]
      end
    end
  end

  find[patha, @tree]
end
fs() click to toggle source
# File lib/proxyfs.rb, line 92
def fs
  @@fs
end