Flowdock
method

binwrite

Importance_1
v1_9_3_392 - Show latest stable - 0 notes - Class: IO
binwrite(*args) public

Opens the file, optionally seeks to the given offset, writes string then returns the length written. binwrite ensures the file is closed before returning. The open mode would be “wb:ASCII-8BIT”. If offset is not given, the file is truncated. Otherwise, it is not truncated.

IO.binwrite("testfile", "0123456789", 20) # => 10
# File could contain:  "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
IO.binwrite("testfile", "0123456789")      #=> 10
# File would now read: "0123456789"
Show source
Register or log in to add new notes.