Module: RIO::IF::File

Included in:
Rio
Defined in:
lib/rio/if/file.rb

Instance Method Summary collapse

Instance Method Details

#clearObject



66
# File 'lib/rio/if/file.rb', line 66

def clear() target.clear(); self end

#rmObject

Calls FileUtils#rm

Deletes the referenced file, returning the Rio. Raises an exception on any error.

See also #delete[rdoc-ref:IF::Grande#delete], #delete![rdoc-ref:IF::Grande#delete!], #rmdir[rdoc-ref:IF::Dir#rmdir].



33
# File 'lib/rio/if/file.rb', line 33

def rm() target.rm(); self end

#touchObject

Calls FileUtils#touch

Updates modification time (mtime) and access time (atime) of a Rio. A file is created if it doesn't exist.



41
# File 'lib/rio/if/file.rb', line 41

def touch() target.touch(); self end

#truncate(sz = pos()) ⇒ Object

Calls File#truncate

Truncates a file referenced by a Rio to be at most sz bytes long. Not available on all platforms.

f = rio("out") f.print!("1234567890") f.size #=> 10 f.truncate(5) f.size() #=> 5

If called with no arguments, truncates the Rio at the value returned by #posrdoc-ref:IF::FileOrDir#pos. f.read(2) f.truncate.size #=> 2 f.contents #=> "12"

Returns the Rio



62
# File 'lib/rio/if/file.rb', line 62

def truncate(sz=pos()) target.truncate(sz); self end