Class: FileSystem::MockFileSystem::MockFile
- Inherits:
-
StringIO
- Object
- StringIO
- FileSystem::MockFileSystem::MockFile
- Includes:
- Node
- Defined in:
- lib/filesystem.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#contents ⇒ Object
writeonly
Sets the attribute contents.
Attributes included from Node
#mtime, #name, #parent, #permissions
Instance Method Summary collapse
- #clone ⇒ Object
- #delete ⇒ Object
- #gets(sep_string = $/) ⇒ Object
-
#initialize(parent, name, contents) ⇒ MockFile
constructor
A new instance of MockFile.
- #rewind ⇒ Object
Constructor Details
#initialize(parent, name, contents) ⇒ MockFile
Returns a new instance of MockFile.
282 283 284 285 |
# File 'lib/filesystem.rb', line 282 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 (writeonly)
Sets the attribute contents
280 281 282 |
# File 'lib/filesystem.rb', line 280 def contents=(value) @contents = value end |
Instance Method Details
#clone ⇒ Object
287 288 289 290 291 292 |
# File 'lib/filesystem.rb', line 287 def clone rewind clone = self.class.new( @parent, @name, gets( nil ) ) clone.mtime = @mtime clone end |
#delete ⇒ Object
294 |
# File 'lib/filesystem.rb', line 294 def delete; parent.delete( self ); end |
#gets(sep_string = $/) ⇒ Object
296 297 298 |
# File 'lib/filesystem.rb', line 296 def gets( sep_string = $/ ) @contents ? super( sep_string ) : nil end |
#rewind ⇒ Object
300 |
# File 'lib/filesystem.rb', line 300 def rewind; @contents ? super : nil; end |