Method: File.write
- Defined in:
- lib/core/facets/file/write.rb
.write(path, data) ⇒ Object
Writes the given data to the given path and closes the file. This is done in binary mode, complementing IO.read in standard Ruby.
str = 'The content for the file'
File.write('write.txt', str)
Returns the number of bytes written.
CREDIT: Gavin Sinclair
15 16 17 18 19 |
# File 'lib/core/facets/file/write.rb', line 15 def self.write(path, data) File.open(path, "wb") do |file| return file.write(data) end end |