class InVFS::MultipleDirectory

Attributes

dirs[R]

Public Class Methods

new(*dirs) click to toggle source
# File lib/invfs/unionfs.rb, line 9
def initialize(*dirs)
  @dirs = dirs
end

Public Instance Methods

file?(lib) click to toggle source
# File lib/invfs/unionfs.rb, line 13
def file?(lib)
  dirs.each do |dir|
    path = File.join(dir, lib)
    return true if File.file?(path)
  end

  false
end
inspect() click to toggle source
# File lib/invfs/unionfs.rb, line 48
def inspect
  to_s
end
pretty_print(q) click to toggle source
# File lib/invfs/unionfs.rb, line 52
def pretty_print(q)
  q.group(2, "#<#{self.class}", ">") do
    dirs.each_with_index do |d, i|
      q.text "," if i > 0
      q.breakable " "
      d.pretty_print q
    end
  end
end
read(lib) click to toggle source
# File lib/invfs/unionfs.rb, line 31
def read(lib)
  dirs.each do |dir|
    path = File.join(dir, lib)
    return File.binread(path) if File.file?(path)
  end

  raise Errno::ENOENT, lib
end
size(lib) click to toggle source
# File lib/invfs/unionfs.rb, line 22
def size(lib)
  dirs.each do |dir|
    path = File.join(dir, lib)
    return File.size(path) if File.file?(path)
  end

  raise Errno::ENOENT, lib
end
to_path() click to toggle source
# File lib/invfs/unionfs.rb, line 40
def to_path
  %(#<#{self.class} #{dirs.map { |d| "<#{d}>" }.join(", ")}>)
end
to_s() click to toggle source
# File lib/invfs/unionfs.rb, line 44
def to_s
  to_path
end