Class: FakeFS::FakeInode
- Inherits:
-
Object
- Object
- FakeFS::FakeInode
- Defined in:
- lib/fakefs/fake/inode.rb
Overview
Inode class
Class Attribute Summary collapse
-
.freed_inodes ⇒ Object
Returns the value of attribute freed_inodes.
-
.next_inode_num ⇒ Object
Returns the value of attribute next_inode_num.
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#inode_num ⇒ Object
Returns the value of attribute inode_num.
-
#links ⇒ Object
Returns the value of attribute links.
Class Method Summary collapse
-
.clear_inode_info_for_tests ⇒ Object
This method should only be used for tests When called, it will reset the current inode information of the FakeFS.
Instance Method Summary collapse
- #assign_inode_num ⇒ Object
- #clone ⇒ Object
- #free_inode_num ⇒ Object
-
#initialize(file_owner) ⇒ FakeInode
constructor
A new instance of FakeInode.
- #link(file) ⇒ Object
- #unlink(file) ⇒ Object
Constructor Details
#initialize(file_owner) ⇒ FakeInode
Returns a new instance of FakeInode.
7 8 9 10 11 |
# File 'lib/fakefs/fake/inode.rb', line 7 def initialize(file_owner) @content = ''.encode(Encoding.default_external) @links = [file_owner] assign_inode_num end |
Class Attribute Details
.freed_inodes ⇒ Object
Returns the value of attribute freed_inodes.
19 20 21 |
# File 'lib/fakefs/fake/inode.rb', line 19 def freed_inodes @freed_inodes end |
.next_inode_num ⇒ Object
Returns the value of attribute next_inode_num.
20 21 22 |
# File 'lib/fakefs/fake/inode.rb', line 20 def next_inode_num @next_inode_num end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
13 14 15 |
# File 'lib/fakefs/fake/inode.rb', line 13 def content @content end |
#inode_num ⇒ Object
Returns the value of attribute inode_num.
15 16 17 |
# File 'lib/fakefs/fake/inode.rb', line 15 def inode_num @inode_num end |
#links ⇒ Object
Returns the value of attribute links.
14 15 16 |
# File 'lib/fakefs/fake/inode.rb', line 14 def links @links end |
Class Method Details
.clear_inode_info_for_tests ⇒ Object
This method should only be used for tests When called, it will reset the current inode information of the FakeFS
24 25 26 27 |
# File 'lib/fakefs/fake/inode.rb', line 24 def clear_inode_info_for_tests self.freed_inodes = [] self.next_inode_num = 0 end |
Instance Method Details
#assign_inode_num ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/fakefs/fake/inode.rb', line 30 def assign_inode_num if (@inode_num = self.class.freed_inodes.shift) else @inode_num = self.class.next_inode_num self.class.next_inode_num += 1 end end |
#clone ⇒ Object
51 52 53 54 55 56 |
# File 'lib/fakefs/fake/inode.rb', line 51 def clone clone = super clone.content = content.dup clone.assign_inode_num clone end |
#free_inode_num ⇒ Object
38 39 40 |
# File 'lib/fakefs/fake/inode.rb', line 38 def free_inode_num self.class.freed_inodes.push(@inode_num) end |
#link(file) ⇒ Object
42 43 44 45 |
# File 'lib/fakefs/fake/inode.rb', line 42 def link(file) links << file unless links.include?(file) file.inode = self end |
#unlink(file) ⇒ Object
47 48 49 |
# File 'lib/fakefs/fake/inode.rb', line 47 def unlink(file) links.delete(file) end |