Class: File
- Object
- File
encoding: utf-8
Public Visibility
Public Class Method Summary
add(file, *chunks) |
Append given chunks to the existing file or create new one. Returns: String |
---|---|
append(file, *chunks) |
Append given chunks to the existing file or create new one. Returns: String |
print(file, *chunks) |
Create new file and write there given chunks. Returns: String |
puts(file, *chunks) |
Create new file and write there given chunks. Returns: String |
write(method, mode, file, *args) |
Write data to file with given method. Returns: String |
Public Instance Methods Inherited from Object
Public Class Method Details
add
Append given chunks to the existing file or create new one. It use IO#print for write to given file.
28 29 30 |
# File 'lib/rango/ext/file.rb', line 28 def self.add(file, *chunks) self.write(:print, "a", file, *chunks) end |
append
Append given chunks to the existing file or create new one. It use IO#puts for write to given file.
14 15 16 |
# File 'lib/rango/ext/file.rb', line 14 def self.append(file, *chunks) self.write(:puts, "a", file, *chunks) end |
Create new file and write there given chunks. It use IO#print for write to given file.
56 57 58 |
# File 'lib/rango/ext/file.rb', line 56 def self.print(file, *chunks) self.write(:print, "w", file, *chunks) end |
puts
Create new file and write there given chunks. It use IO#puts for write to given file.
42 43 44 |
# File 'lib/rango/ext/file.rb', line 42 def self.puts(file, *chunks) self.write(:puts, "w", file, *chunks) end |
write
Write data to file with given method.
69 70 71 72 73 |
# File 'lib/rango/ext/file.rb', line 69 def self.write(method, mode, file, *args) self.(file).tap do |path| self.open(path, mode) { |file| file.send(method, *args) } end end |