Class: MockFS::MockFileSystem::MockFile
- Inherits:
-
StringIO
- Object
- StringIO
- MockFS::MockFileSystem::MockFile
show all
- Includes:
- Node
- Defined in:
- lib/mockfs.rb
Overview
Instance Attribute Summary collapse
Attributes included from Node
#mtime, #name, #parent, #permissions
Instance Method Summary
collapse
Methods included from Node
#readable?
Constructor Details
#initialize(parent, name, contents) ⇒ MockFile
Returns a new instance of MockFile.
486
487
488
489
|
# File 'lib/mockfs.rb', line 486
def initialize( parent, name, contents )
@name = name; @parent = parent; @mtime = Time.now; @contents = contents
super( StringIO.new( contents ) ) if contents
end
|
Instance Attribute Details
#contents=(value) ⇒ Object
Sets the attribute contents
484
485
486
|
# File 'lib/mockfs.rb', line 484
def contents=(value)
@contents = value
end
|
Instance Method Details
#clone ⇒ Object
491
492
493
494
495
496
497
|
# File 'lib/mockfs.rb', line 491
def clone
rewind
clone = self.class.new( @parent, @name, gets( nil ) )
rewind
clone.mtime = @mtime
clone
end
|
#close ⇒ Object
499
|
# File 'lib/mockfs.rb', line 499
def close; rewind; end
|
#delete ⇒ Object
501
|
# File 'lib/mockfs.rb', line 501
def delete; parent.delete( self ); end
|
#gets(sep_string = $/) ⇒ Object
503
504
505
|
# File 'lib/mockfs.rb', line 503
def gets( sep_string = $/ )
@contents ? super( sep_string ) : nil
end
|
#rewind ⇒ Object
507
|
# File 'lib/mockfs.rb', line 507
def rewind; @contents ? super : nil; end
|