Module: File::Write

Included in:
File
Defined in:
lib/vex/base/filesystem/write.rb

Defined Under Namespace

Modules: Etest

Instance Method Summary collapse

Instance Method Details

#touch(*files) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/vex/base/filesystem/write.rb', line 2

def touch(*files)
  opts = if files.last.is_a?(Hash)
    files.pop
  else
    {}
  end
  
  files.each do |file|
    if File.exists?(file)
      File.open(file, "a") {}
    else
      File.write(file, opts[:content])
    end
  end
end

#write(path, data) ⇒ Object



18
19
20
21
22
23
# File 'lib/vex/base/filesystem/write.rb', line 18

def write(path, data)
  File.open(path, "w+") do |file|
    file.write(data) if data
  end
  path
end