Class: FakeFS::FakeFile

Inherits:
Object
  • Object
show all
Defined in:
lib/fakefs/fake/file.rb

Defined Under Namespace

Classes: Inode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, parent = nil) ⇒ FakeFile

Returns a new instance of FakeFile.



31
32
33
34
35
36
37
# File 'lib/fakefs/fake/file.rb', line 31

def initialize(name = nil, parent = nil)
  @name   = name
  @parent = parent
  @inode  = Inode.new(self)
  @ctime  = Time.now
  @mtime  = @ctime
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



3
4
5
# File 'lib/fakefs/fake/file.rb', line 3

def content
  @content
end

#ctimeObject (readonly)

Returns the value of attribute ctime.



4
5
6
# File 'lib/fakefs/fake/file.rb', line 4

def ctime
  @ctime
end

#inodeObject

Returns the value of attribute inode.



39
40
41
# File 'lib/fakefs/fake/file.rb', line 39

def inode
  @inode
end

#mtimeObject

Returns the value of attribute mtime.



3
4
5
# File 'lib/fakefs/fake/file.rb', line 3

def mtime
  @mtime
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/fakefs/fake/file.rb', line 3

def name
  @name
end

#parentObject

Returns the value of attribute parent.



3
4
5
# File 'lib/fakefs/fake/file.rb', line 3

def parent
  @parent
end

Instance Method Details

#clone(parent = nil) ⇒ Object



57
58
59
60
61
62
# File 'lib/fakefs/fake/file.rb', line 57

def clone(parent = nil)
  clone = super()
  clone.parent = parent if parent
  clone.inode  = inode.clone
  clone
end

#deleteObject



76
77
78
79
# File 'lib/fakefs/fake/file.rb', line 76

def delete
  inode.unlink(self)
  parent.delete(self)
end

#entryObject



64
65
66
# File 'lib/fakefs/fake/file.rb', line 64

def entry
  self
end

#inspectObject



68
69
70
# File 'lib/fakefs/fake/file.rb', line 68

def inspect
  "(FakeFile name:#{name.inspect} parent:#{parent.to_s.inspect} size:#{content.size})"
end


53
54
55
# File 'lib/fakefs/fake/file.rb', line 53

def link(other_file)
  @inode.link(other_file)
end


49
50
51
# File 'lib/fakefs/fake/file.rb', line 49

def links
  @inode.links
end

#to_sObject



72
73
74
# File 'lib/fakefs/fake/file.rb', line 72

def to_s
  File.join(parent.to_s, name)
end