Module: TXThelper
- Defined in:
- lib/tabbyx/helpers/txt_helper.rb
Class Method Summary collapse
- .read_file_by_path(file_path) ⇒ Object
-
.read_from_text(filename) ⇒ Object
example: TXThelper.read_from_text(‘api_testcases.csv’).
- .write_array_to_text(array, filename) ⇒ Object
Class Method Details
.read_file_by_path(file_path) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/tabbyx/helpers/txt_helper.rb', line 18 def self.read_file_by_path(file_path) file = File.absolute_path(file_path) data = [] lines = IO.readlines(file) lines.each do |line| data.push line end data end |
.read_from_text(filename) ⇒ Object
example: TXThelper.read_from_text(‘api_testcases.csv’)
8 9 10 11 12 13 14 15 16 |
# File 'lib/tabbyx/helpers/txt_helper.rb', line 8 def self.read_from_text(filename) file = Base.file_exists?(filename) text = [] lines = IO.readlines(file) lines.each do |line| text.push line end text end |
.write_array_to_text(array, filename) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/tabbyx/helpers/txt_helper.rb', line 28 def self.write_array_to_text(array,filename) Base.file_exists?(filename) ? file = Base.file_exists?(filename) : file = Base.create_file(filename) File.open(file,"w") do |line| array.each_with_index { |item,index | line.print(index,":",item);line.puts "\n" } end end |