Method: Files::Files#file

Defined in:
lib/files.rb

#file(name, contents = "contents of #{name}") ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/files.rb', line 84

def file name, contents = "contents of #{name}"
  if name.is_a? File
    FileUtils.cp name.path, current
    # todo: return path
  else
    path = File.join(current, name)
    if contents.is_a? File
      FileUtils.cp contents.path, path
    else
      file_path = File.open(path, "w") do |f|
        f.write contents
      end
    end
    path
  end
end