Module: Lazyportal::Helpers

Defined in:
lib/lazyportal/helpers.rb

Instance Method Summary collapse

Instance Method Details

#create_file(file, contents, modes = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/lazyportal/helpers.rb', line 3

def create_file file, contents, modes={}
  mode = case
    when modes[:noclobber] then "a+"
    when modes[:read_only] then "r"
    else "w+"
  end
  
  File.open(file, mode) { |f| f.write(contents) }
end