class MemFs::Fake::Directory
Attributes
Public Class Methods
Source
# File lib/memfs/fake/directory.rb, line 32 def initialize(*args) super self.entries = { '.' => self, '..' => nil } end
Calls superclass method
Public Instance Methods
Source
# File lib/memfs/fake/directory.rb, line 8 def add_entry(entry) entries[entry.name] = entry entry.parent = self end
Source
# File lib/memfs/fake/directory.rb, line 13 def empty? (entries.keys - %w[. ..]).empty? end
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
Source
# File lib/memfs/fake/directory.rb, line 37 def parent=(parent) super entries['..'] = parent end
Calls superclass method
Source
# File lib/memfs/fake/directory.rb, line 42 def path name == '/' ? '/' : super end
Calls superclass method
Source
# File lib/memfs/fake/directory.rb, line 46 def paths [path] + entries.reject { |p| %w[. ..].include?(p) } .values .map(&:paths) .flatten end
Source
# File lib/memfs/fake/directory.rb, line 53 def remove_entry(entry) entries.delete(entry.name) end