module RBT::SaveFile
Public Class Methods
append_what_into(what, into)
click to toggle source
write_what_into( what, into, use_these_permissions = 0755 )
click to toggle source
#¶ ↑
RBT::SaveFile.write_what_into
¶ ↑
This method can be used to write content into a file, via ruby's File.open() functionality.
The official documentation can be found here:
https://ruby-doc.org/core/File.html#method-c-open
#¶ ↑
# File lib/rbt/toplevel_methods/save_file.rb, line 29 def self.write_what_into( what, into, use_these_permissions = 0755 ) case use_these_permissions when :default use_these_permissions = 0755 end base_dir = File.dirname(into) RBT.mkdir(base_dir) unless File.exist? base_dir File.open(into, 'w+', use_these_permissions.to_i) { |file| file.write(what) } # RBT.e "No file exists at #{into}." end