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 modes
    when :noclobber then "a+"
    when :read_only then "r"
    else "w+"
  end
    
  File.open(file, mode) { |f| f.write(contents) }
end