class MemFs::Fake::Directory
Attributes
entries[RW]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/memfs/fake/directory.rb, line 32 def initialize(*args) super self.entries = { '.' => self, '..' => nil } end
Public Instance Methods
add_entry(entry)
click to toggle source
# File lib/memfs/fake/directory.rb, line 8 def add_entry(entry) entries[entry.name] = entry entry.parent = self end
empty?()
click to toggle source
# File lib/memfs/fake/directory.rb, line 13 def empty? (entries.keys - %w[. ..]).empty? end
entry_names()
click to toggle source
# File lib/memfs/fake/directory.rb, line 17 def entry_names entries.keys end
find(path)
click to toggle source
# File lib/memfs/fake/directory.rb, line 21 def find(path) path = path.sub(%r{\A/+}, '').sub(%r{/+\z}, '') parts = path.split('/', 2) if entry_names.include?(path) entries[path] elsif entry_names.include?(parts.first) entries[parts.first].find(parts.last) end end
parent=(parent)
click to toggle source
Calls superclass method
# File lib/memfs/fake/directory.rb, line 37 def parent=(parent) super entries['..'] = parent end
path()
click to toggle source
Calls superclass method
# File lib/memfs/fake/directory.rb, line 42 def path name == '/' ? '/' : super end
paths()
click to toggle source
# File lib/memfs/fake/directory.rb, line 46 def paths [path] + entries.reject { |p| %w[. ..].include?(p) } .values .map(&:paths) .flatten end
remove_entry(entry)
click to toggle source
# File lib/memfs/fake/directory.rb, line 53 def remove_entry(entry) entries.delete(entry.name) end
type()
click to toggle source
# File lib/memfs/fake/directory.rb, line 57 def type 'directory' end