Class: MemFs::Fake::File

Inherits:
Entry
  • Object
show all
Defined in:
lib/memfs/fake/file.rb,
lib/memfs/fake/file/content.rb

Defined Under Namespace

Classes: Content

Constant Summary

Constants inherited from Entry

Entry::GEXEC, Entry::GREAD, Entry::GWRITE, Entry::OEXEC, Entry::OREAD, Entry::OWRITE, Entry::RSTICK, Entry::SETGID, Entry::SETUID, Entry::UEXEC, Entry::UREAD, Entry::USTICK, Entry::UWRITE

Instance Attribute Summary collapse

Attributes inherited from Entry

#atime, #block_device, #character_device, #ctime, #gid, #mode, #mtime, #name, #parent, #uid

Instance Method Summary collapse

Methods inherited from Entry

#blksize, #delete, #dereferenced, #dereferenced_name, #dereferenced_path, #dev, #find, #ino, #path, #paths, #touch

Constructor Details

#initialize(*args) ⇒ File

Returns a new instance of File.



17
18
19
20
21
# File 'lib/memfs/fake/file.rb', line 17

def initialize(*args)
  super
  @content = Content.new
  @closed = false
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



7
8
9
# File 'lib/memfs/fake/file.rb', line 7

def content
  @content
end

Instance Method Details

#closeObject



9
10
11
# File 'lib/memfs/fake/file.rb', line 9

def close
  @closed = true
end

#closed?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/memfs/fake/file.rb', line 13

def closed?
  @closed
end

#posObject



23
24
25
# File 'lib/memfs/fake/file.rb', line 23

def pos
  content.pos
end

#pos=(value) ⇒ Object



27
28
29
# File 'lib/memfs/fake/file.rb', line 27

def pos=(value)
  content.pos = value
end

#sizeObject



31
32
33
# File 'lib/memfs/fake/file.rb', line 31

def size
  content.size
end

#typeObject



35
36
37
38
39
40
41
# File 'lib/memfs/fake/file.rb', line 35

def type
  case
  when block_device     then 'blockSpecial'
  when character_device then 'characterSpecial'
  else 'file'
  end
end