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, #birthtime, #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, #fileno, #find, #ino, #path, #paths, #touch

Constructor Details

#initialize(*args) ⇒ File

Returns a new instance of File.



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

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

Instance Attribute Details

#contentObject

Returns the value of attribute content.



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

def content
  @content
end

Instance Method Details

#closeObject



11
12
13
# File 'lib/memfs/fake/file.rb', line 11

def close
  @closed = true
end

#closed?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/memfs/fake/file.rb', line 15

def closed?
  @closed
end

#posObject



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

def pos
  content.pos
end

#pos=(value) ⇒ Object



29
30
31
# File 'lib/memfs/fake/file.rb', line 29

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

#sizeObject



33
34
35
# File 'lib/memfs/fake/file.rb', line 33

def size
  content.size
end

#typeObject



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

def type
  return 'blockSpecial' if block_device
  return 'characterSpecial' if character_device

  'file'
end