Class: FakeFS::FakeFile::Inode

Inherits:
Object
  • Object
show all
Defined in:
lib/fakefs/fake/file.rb

Overview

Inode class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_owner) ⇒ Inode

Returns a new instance of Inode.



9
10
11
12
13
14
15
# File 'lib/fakefs/fake/file.rb', line 9

def initialize(file_owner)
  # 1.9.3 when possible set default external encoding
  @content = ''
  @content = ''.encode(
    Encoding.default_external) if ''.respond_to?(:encode)
  @links   = [file_owner]
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



17
18
19
# File 'lib/fakefs/fake/file.rb', line 17

def content
  @content
end

Returns the value of attribute links.



18
19
20
# File 'lib/fakefs/fake/file.rb', line 18

def links
  @links
end

Instance Method Details

#cloneObject



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

def clone
  clone = super
  clone.content = content.dup
  clone
end


20
21
22
23
# File 'lib/fakefs/fake/file.rb', line 20

def link(file)
  links << file unless links.include?(file)
  file.inode = self
end


25
26
27
# File 'lib/fakefs/fake/file.rb', line 25

def unlink(file)
  links.delete(file)
end