Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/flogger/ext/file.rb
Class Method Summary collapse
-
.open_or_create(file, access) ⇒ Object
create a file if it doesn’t already exist.
Class Method Details
.open_or_create(file, access) ⇒ Object
create a file if it doesn’t already exist
5 6 7 8 9 10 11 12 13 |
# File 'lib/flogger/ext/file.rb', line 5 def self.open_or_create(file, access) begin path = File.dirname(file) FileUtils.mkdir_p(path) unless File.exists?(file) File.open(file, access) rescue Exception => e $stderr.puts e. end end |