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.
9 10 11 12 13 |
# File 'lib/fakefs/fake/inode.rb', line 9 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.
19 20 21 |
# File 'lib/fakefs/fake/inode.rb', line 19 def next_inode_num @next_inode_num end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
15 16 17 |
# File 'lib/fakefs/fake/inode.rb', line 15 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.
15 16 17 |
# File 'lib/fakefs/fake/inode.rb', line 15 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
23 24 25 26 |
# File 'lib/fakefs/fake/inode.rb', line 23 def clear_inode_info_for_tests self.freed_inodes = [] self.next_inode_num = 0 end |
Instance Method Details
#assign_inode_num ⇒ Object
29 30 31 32 33 34 |
# File 'lib/fakefs/fake/inode.rb', line 29 def assign_inode_num unless (@inode_num = self.class.freed_inodes.shift) @inode_num = self.class.next_inode_num self.class.next_inode_num += 1 end end |
#clone ⇒ Object
49 50 51 52 53 54 |
# File 'lib/fakefs/fake/inode.rb', line 49 def clone clone = super clone.content = content.dup clone.assign_inode_num clone end |
#free_inode_num ⇒ Object
36 37 38 |
# File 'lib/fakefs/fake/inode.rb', line 36 def free_inode_num self.class.freed_inodes.push(@inode_num) end |
#link(file) ⇒ Object
40 41 42 43 |
# File 'lib/fakefs/fake/inode.rb', line 40 def link(file) links << file unless links.include?(file) file.inode = self end |
#unlink(file) ⇒ Object
45 46 47 |
# File 'lib/fakefs/fake/inode.rb', line 45 def unlink(file) links.delete(file) end |