Class: FileSystem::MockFileSystem::MockFile

Inherits:
StringIO
  • Object
show all
Includes:
Node
Defined in:
lib/filesystem.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes included from Node

#mtime, #name, #parent, #permissions

Instance Method Summary collapse

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

Parameters:

  • value

    the value to set the attribute contents to.



280
281
282
# File 'lib/filesystem.rb', line 280

def contents=(value)
  @contents = value
end

Instance Method Details

#cloneObject



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

#deleteObject



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

#rewindObject



300
# File 'lib/filesystem.rb', line 300

def rewind; @contents ? super : nil; end