Class: File

Inherits:
Object show all
Defined in:
lib/RubyExt/file.rb

Class Method Summary collapse

Class Method Details

.create_directory(dir) ⇒ Object



15
16
17
# File 'lib/RubyExt/file.rb', line 15

def create_directory dir
  Dir.mkdir dir unless File.exist? dir
end

.delete_directory(dir) ⇒ Object



19
20
21
# File 'lib/RubyExt/file.rb', line 19

def delete_directory dir
  FileUtils.rm_r dir, :force => true if File.exist? dir
end

.read(path) ⇒ Object



9
10
11
12
13
# File 'lib/RubyExt/file.rb', line 9

def read(path)
  File.open(path, "rb") do |file|
    return file.read
  end
end

.write(path, data) ⇒ Object



3
4
5
6
7
# File 'lib/RubyExt/file.rb', line 3

def write(path, data)
  File.open(path, "wb") do |file|
    return file.write(data)
  end
end