Class: MemFs::Fake::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/memfs/fake/entry.rb

Direct Known Subclasses

Directory, File, Symlink

Constant Summary collapse

UREAD =
00100
UWRITE =
00200
UEXEC =
00400
GREAD =
00010
GWRITE =
00020
GEXEC =
00040
OREAD =
00001
OWRITE =
00002
OEXEC =
00004
RSTICK =
01000
USTICK =
05000
SETUID =
04000
SETGID =
02000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Entry

Returns a new instance of Entry.



57
58
59
60
61
62
63
64
65
66
# File 'lib/memfs/fake/entry.rb', line 57

def initialize(path = nil)
  time = Time.now
  self.atime = time
  self.ctime = time
  self.gid = Process.egid
  self.mode = 0666 - MemFs::File.umask
  self.mtime = time
  self.name = MemFs::File.basename(path || '')
  self.uid = Process.euid
end

Instance Attribute Details

#atimeObject

Returns the value of attribute atime.



18
19
20
# File 'lib/memfs/fake/entry.rb', line 18

def atime
  @atime
end

#block_deviceObject

Returns the value of attribute block_device.



18
19
20
# File 'lib/memfs/fake/entry.rb', line 18

def block_device
  @block_device
end

#character_deviceObject

Returns the value of attribute character_device.



18
19
20
# File 'lib/memfs/fake/entry.rb', line 18

def character_device
  @character_device
end

#ctimeObject

Returns the value of attribute ctime.



18
19
20
# File 'lib/memfs/fake/entry.rb', line 18

def ctime
  @ctime
end

#gidObject

Returns the value of attribute gid.



18
19
20
# File 'lib/memfs/fake/entry.rb', line 18

def gid
  @gid
end

#modeObject

Returns the value of attribute mode.



27
28
29
# File 'lib/memfs/fake/entry.rb', line 27

def mode
  @mode
end

#mtimeObject

Returns the value of attribute mtime.



18
19
20
# File 'lib/memfs/fake/entry.rb', line 18

def mtime
  @mtime
end

#nameObject

Returns the value of attribute name.



18
19
20
# File 'lib/memfs/fake/entry.rb', line 18

def name
  @name
end

#parentObject

Returns the value of attribute parent.



18
19
20
# File 'lib/memfs/fake/entry.rb', line 18

def parent
  @parent
end

#uidObject

Returns the value of attribute uid.



18
19
20
# File 'lib/memfs/fake/entry.rb', line 18

def uid
  @uid
end

Instance Method Details

#blksizeObject



29
30
31
# File 'lib/memfs/fake/entry.rb', line 29

def blksize
  4096
end

#deleteObject



33
34
35
# File 'lib/memfs/fake/entry.rb', line 33

def delete
  parent.remove_entry self
end

#dereferencedObject



37
38
39
# File 'lib/memfs/fake/entry.rb', line 37

def dereferenced
  self
end

#dereferenced_nameObject



41
42
43
# File 'lib/memfs/fake/entry.rb', line 41

def dereferenced_name
  name
end

#dereferenced_pathObject



45
46
47
# File 'lib/memfs/fake/entry.rb', line 45

def dereferenced_path
  path
end

#devObject



49
50
51
# File 'lib/memfs/fake/entry.rb', line 49

def dev
  @dev ||= rand(1000)
end

#find(_path) ⇒ Object



53
54
55
# File 'lib/memfs/fake/entry.rb', line 53

def find(_path)
  fail Errno::ENOTDIR, path
end

#inoObject



68
69
70
# File 'lib/memfs/fake/entry.rb', line 68

def ino
  @ino ||= rand(1000)
end

#pathObject



76
77
78
79
# File 'lib/memfs/fake/entry.rb', line 76

def path
  parts = [parent && parent.path, name].compact
  MemFs::File.join(parts)
end

#pathsObject



81
82
83
# File 'lib/memfs/fake/entry.rb', line 81

def paths
  [path]
end

#touchObject



85
86
87
# File 'lib/memfs/fake/entry.rb', line 85

def touch
  self.atime = self.mtime = Time.now
end

#typeObject



89
90
91
# File 'lib/memfs/fake/entry.rb', line 89

def type
  'unknown'
end