Class: IFD_File

Inherits:
Object
  • Object
show all
Defined in:
lib/helper/file_helper.rb

Class Method Summary collapse

Class Method Details

.delete_file(file_name) ⇒ Object



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

def self.delete_file(file_name)
  file_path = ($test_data_dir + file_name.gsub(" ", "_"))
  if File.exists?(file_path)
    File.delete(file_path)
    puts "#{file_name} is deleted successfully"
  else
    puts "File #{file_name} does not exists"
  end
end

.execute_windows_file(filename, file_location) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/helper/file_helper.rb', line 26

def self.execute_windows_file(filename, file_location)
  file = file_location + filename
  p file
  if File.exist? file
    system("'"+file+"'")
  else
    raise "*** ERROR: File #{file} is not existed."
  end
end

.read_file(file_name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/helper/file_helper.rb', line 13

def self.read_file(file_name)
  @file_data = ""
  file_path = $test_data_dir + file_name.downcase
  if File.exist?(file_path)
    file = File.open(file_path)
    @file_data += file.read
    file.close
  else
    raise "*** WARNING: File #{file_name} does not exist."
  end
  p @file_data
end