Class: FakeFS::FakeFile
- Inherits:
-
Object
- Object
- FakeFS::FakeFile
- Defined in:
- lib/fakefs/fake/file.rb
Overview
Fake file class
Defined Under Namespace
Classes: Inode
Instance Attribute Summary collapse
-
#atime ⇒ Object
Returns the value of attribute atime.
-
#birthtime ⇒ Object
readonly
Returns the value of attribute birthtime.
-
#ctime ⇒ Object
readonly
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.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fakefs/fake/file.rb', line 36 def initialize(name = nil, parent = nil) @name = name @parent = parent @inode = Inode.new(self) @ctime = Time.now @mtime = @ctime @atime = @ctime @birthtime = @ctime @mode = 0100000 + (0666 - File.umask) @uid = Process.uid @gid = Process.gid end |
Instance Attribute Details
#atime ⇒ Object
Returns the value of attribute atime.
4 5 6 |
# File 'lib/fakefs/fake/file.rb', line 4 def atime @atime end |
#birthtime ⇒ Object (readonly)
Returns the value of attribute birthtime.
5 6 7 |
# File 'lib/fakefs/fake/file.rb', line 5 def birthtime @birthtime end |
#ctime ⇒ Object (readonly)
Returns the value of attribute ctime.
5 6 7 |
# File 'lib/fakefs/fake/file.rb', line 5 def ctime @ctime end |
#gid ⇒ Object
Returns the value of attribute gid.
4 5 6 |
# File 'lib/fakefs/fake/file.rb', line 4 def gid @gid end |
#inode ⇒ Object
Returns the value of attribute inode.
49 50 51 |
# File 'lib/fakefs/fake/file.rb', line 49 def inode @inode end |
#mode ⇒ Object
Returns the value of attribute mode.
4 5 6 |
# File 'lib/fakefs/fake/file.rb', line 4 def mode @mode end |
#mtime ⇒ Object
Returns the value of attribute mtime.
4 5 6 |
# File 'lib/fakefs/fake/file.rb', line 4 def mtime @mtime end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/fakefs/fake/file.rb', line 4 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
4 5 6 |
# File 'lib/fakefs/fake/file.rb', line 4 def parent @parent end |
#uid ⇒ Object
Returns the value of attribute uid.
4 5 6 |
# File 'lib/fakefs/fake/file.rb', line 4 def uid @uid end |
Instance Method Details
#clone(parent = nil) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/fakefs/fake/file.rb', line 67 def clone(parent = nil) clone = super() clone.parent = parent if parent clone.inode = inode.clone clone end |
#content ⇒ Object
51 52 53 |
# File 'lib/fakefs/fake/file.rb', line 51 def content @inode.content end |
#content=(str) ⇒ Object
55 56 57 |
# File 'lib/fakefs/fake/file.rb', line 55 def content=(str) @inode.content = str end |
#delete ⇒ Object
87 88 89 90 |
# File 'lib/fakefs/fake/file.rb', line 87 def delete inode.unlink(self) parent.delete(self) end |
#entry ⇒ Object
74 75 76 |
# File 'lib/fakefs/fake/file.rb', line 74 def entry self end |
#inspect ⇒ Object
78 79 80 81 |
# File 'lib/fakefs/fake/file.rb', line 78 def inspect "(FakeFile name:#{name.inspect} " \ "parent:#{parent.to_s.inspect} size:#{content.size})" end |
#link(other_file) ⇒ Object
63 64 65 |
# File 'lib/fakefs/fake/file.rb', line 63 def link(other_file) @inode.link(other_file) end |
#links ⇒ Object
59 60 61 |
# File 'lib/fakefs/fake/file.rb', line 59 def links @inode.links end |
#to_s ⇒ Object
83 84 85 |
# File 'lib/fakefs/fake/file.rb', line 83 def to_s File.join(parent.to_s, name) end |