Class: File
Overview
File extension.
Class Method Summary collapse
-
.touch(filepath) ⇒ Object
Creates file with zero size and closes it.
-
.write(filepath, data = "") ⇒ Integer
Writes data to file and closes it in single call.
Class Method Details
.touch(filepath) ⇒ Object
Creates file with zero size and closes it. (In fact, touch
is usually used for it.)
37 38 39 |
# File 'lib/hash-utils/file.rb', line 37 def self.touch(filepath) File.open(filepath, "wb").close() end |
.write(filepath, data = "") ⇒ Integer
Writes data to file and closes it in single call. Data are written in binary mode since 0.11.1
.
21 22 23 24 25 26 27 |
# File 'lib/hash-utils/file.rb', line 21 def self.write(filepath, data = "") len = nil File.open(filepath, "wb") do |io| len = io.write(data) end return len end |