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.



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

def initialize(name = nil, parent = nil)
  @name   = name
  @parent = parent
  @inode  = Inode.new(self)
  @mtime  = Time.now
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

#inodeObject

Returns the value of attribute inode.



37
38
39
# File 'lib/fakefs/fake/file.rb', line 37

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



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

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

#deleteObject



74
75
76
77
# File 'lib/fakefs/fake/file.rb', line 74

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

#entryObject



62
63
64
# File 'lib/fakefs/fake/file.rb', line 62

def entry
  self
end

#inspectObject



66
67
68
# File 'lib/fakefs/fake/file.rb', line 66

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


51
52
53
# File 'lib/fakefs/fake/file.rb', line 51

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


47
48
49
# File 'lib/fakefs/fake/file.rb', line 47

def links
  @inode.links
end

#to_sObject



70
71
72
# File 'lib/fakefs/fake/file.rb', line 70

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