Class: File
Class Method Summary collapse
-
.add(file, *chunks) ⇒ String
Append given chunks to the existing file or create new one.
-
.append(file, *chunks) ⇒ String
Append given chunks to the existing file or create new one.
-
.print(file, *chunks) ⇒ String
Create new file and write there given chunks.
-
.puts(file, *chunks) ⇒ String
Create new file and write there given chunks.
-
.write(method, mode, file, *args) ⇒ String
Write data to file with given method.
Class Method Details
.add(file, *chunks) ⇒ String
Append given chunks to the existing file or create new one. It use IO#print
for write to given file.
32 33 34 |
# File 'lib/rubyexts/file.rb', line 32 def self.add(file, *chunks) self.write(:print, "a", file, *chunks) end |
.append(file, *chunks) ⇒ String
Append given chunks to the existing file or create new one. It use IO#puts
for write to given file.
16 17 18 |
# File 'lib/rubyexts/file.rb', line 16 def self.append(file, *chunks) self.write(:puts, "a", file, *chunks) end |
.print(file, *chunks) ⇒ String
Create new file and write there given chunks. It use IO#print
for write to given file.
64 65 66 |
# File 'lib/rubyexts/file.rb', line 64 def self.print(file, *chunks) self.write(:print, "w", file, *chunks) end |
.puts(file, *chunks) ⇒ String
Create new file and write there given chunks. It use IO#puts
for write to given file.
48 49 50 |
# File 'lib/rubyexts/file.rb', line 48 def self.puts(file, *chunks) self.write(:puts, "w", file, *chunks) end |
.write(method, mode, file, *args) ⇒ String
Write data to file with given method.
79 80 81 82 83 |
# File 'lib/rubyexts/file.rb', line 79 def self.write(method, mode, file, *args) self.(file).tap do |path| self.open(path, mode) { |file| file.send(method, *args) } end end |