Class: File
Overview
File extension.
Class Method Summary collapse
-
.binwrite(filepath, data = "") ⇒ Integer
Writes binary data to file and closes it in single call.
- .touch(filepath) ⇒ Object
-
.write(filepath, data = "") ⇒ Integer
Writes data to file and closes it in single call.
Class Method Details
.binwrite(filepath, data = "") ⇒ Integer
Note:
Since Ruby 1.9.3 replaced by STL native version.
Writes binary data to file and closes it in single call.
58 59 60 61 62 63 64 |
# File 'lib/hash-utils/file.rb', line 58 def self.binwrite(filepath, data = "") len = nil File.open(filepath, "wb") do |io| len = io.write(data) end return len end |
.touch(filepath) ⇒ Object
78 79 80 |
# File 'lib/hash-utils/file.rb', line 78 def self.touch(filepath) File.open(filepath, "wb").close() end |
.write(filepath, data = "") ⇒ Integer
Note:
Data were written in binary mode since 0.11.1
, but since 0.19.0
, they are written non-binary again. Binary writing is implemented via binwrite.
Note:
Since Ruby 1.9.3 replaced by STL native version.
Writes data to file and closes it in single call.
32 33 34 35 36 37 38 |
# File 'lib/hash-utils/file.rb', line 32 def self.write(filepath, data = "") len = nil File.open(filepath, "w") do |io| len = io.write(data) end return len end |