Class: FakeFS::FakeFile
- Inherits:
-
Object
- Object
- FakeFS::FakeFile
- Defined in:
- lib/fakefs/fake/file.rb
Overview
Fake file class
Instance Attribute Summary collapse
-
#atime ⇒ Object
Returns the value of attribute atime.
-
#birthtime ⇒ Object
Returns the value of attribute birthtime.
-
#ctime ⇒ Object
Returns the value of attribute ctime.
-
#gid ⇒ Object
Returns the value of attribute gid.
-
#inode ⇒ Object
Returns the value of attribute inode.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#mtime ⇒ Object
Returns the value of attribute mtime.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#uid ⇒ Object
Returns the value of attribute uid.
Instance Method Summary collapse
- #clone(parent = nil) ⇒ Object
- #content ⇒ Object
- #content=(str) ⇒ Object
- #delete ⇒ Object
- #entry ⇒ Object
-
#initialize(name = nil, parent = nil) ⇒ FakeFile
constructor
A new instance of FakeFile.
- #inspect ⇒ Object
- #link(other_file) ⇒ Object
- #links ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name = nil, parent = nil) ⇒ FakeFile
Returns a new instance of FakeFile.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fakefs/fake/file.rb', line 8 def initialize(name = nil, parent = nil) @name = name @parent = parent @inode = FakeInode.new(self) @ctime = Time.now @mtime = @ctime @atime = @ctime @birthtime = @ctime @mode = 0o100000 + (0o666 - File.umask) @uid = Process.uid @gid = Process.gid end |
Instance Attribute Details
#atime ⇒ Object
Returns the value of attribute atime.
6 7 8 |
# File 'lib/fakefs/fake/file.rb', line 6 def atime @atime end |
#birthtime ⇒ Object
Returns the value of attribute birthtime.
6 7 8 |
# File 'lib/fakefs/fake/file.rb', line 6 def birthtime @birthtime end |
#ctime ⇒ Object
Returns the value of attribute ctime.
6 7 8 |
# File 'lib/fakefs/fake/file.rb', line 6 def ctime @ctime end |
#gid ⇒ Object
Returns the value of attribute gid.
6 7 8 |
# File 'lib/fakefs/fake/file.rb', line 6 def gid @gid end |
#inode ⇒ Object
Returns the value of attribute inode.
6 7 8 |
# File 'lib/fakefs/fake/file.rb', line 6 def inode @inode end |
#mode ⇒ Object
Returns the value of attribute mode.
6 7 8 |
# File 'lib/fakefs/fake/file.rb', line 6 def mode @mode end |
#mtime ⇒ Object
Returns the value of attribute mtime.
6 7 8 |
# File 'lib/fakefs/fake/file.rb', line 6 def mtime @mtime end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/fakefs/fake/file.rb', line 6 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
6 7 8 |
# File 'lib/fakefs/fake/file.rb', line 6 def parent @parent end |
#uid ⇒ Object
Returns the value of attribute uid.
6 7 8 |
# File 'lib/fakefs/fake/file.rb', line 6 def uid @uid end |
Instance Method Details
#clone(parent = nil) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/fakefs/fake/file.rb', line 37 def clone(parent = nil) clone = super() clone.parent = parent if parent clone.inode = inode.clone clone end |
#content ⇒ Object
21 22 23 |
# File 'lib/fakefs/fake/file.rb', line 21 def content @inode.content end |
#content=(str) ⇒ Object
25 26 27 |
# File 'lib/fakefs/fake/file.rb', line 25 def content=(str) @inode.content = str end |
#delete ⇒ Object
57 58 59 60 61 |
# File 'lib/fakefs/fake/file.rb', line 57 def delete inode.unlink(self) inode.free_inode_num parent.delete(self) end |
#entry ⇒ Object
44 45 46 |
# File 'lib/fakefs/fake/file.rb', line 44 def entry self end |
#inspect ⇒ Object
48 49 50 51 |
# File 'lib/fakefs/fake/file.rb', line 48 def inspect "(FakeFile name:#{name.inspect} " \ "parent:#{parent.to_s.inspect} size:#{content.size})" end |
#link(other_file) ⇒ Object
33 34 35 |
# File 'lib/fakefs/fake/file.rb', line 33 def link(other_file) @inode.link(other_file) end |
#links ⇒ Object
29 30 31 |
# File 'lib/fakefs/fake/file.rb', line 29 def links @inode.links end |