class DataFile2
Public Class Methods
new(filename)
click to toggle source
# File lib/Framework/DataFile2.rb, line 3 def initialize(filename) @filename = filename end
Public Instance Methods
CheckCommands()
click to toggle source
# File lib/Framework/DataFile2.rb, line 7 def CheckCommands file = File.new(@filename, 'r') while (line = file.gets) regexp = Regexp.new("###command:(.*)###") end file.close end
Read(command)
click to toggle source
# File lib/Framework/DataFile2.rb, line 23 def Read(command) data_string = '' regexp_command = Regexp.new(Regexp.escape(command)) regexp = Regexp.new('###command') insite_command = 0 file = File.new(@filename, 'r') while (line = file.gets) match_command = regexp_command.match(line) match = regexp.match(line) if match && match_command insite_command = 1 next elsif match insite_command = 0 end if insite_command == 1 line.delete!("\r") data_string += line end end file.close data_string end
Write(command, value)
click to toggle source
# File lib/Framework/DataFile2.rb, line 15 def Write(command, value) File.open(@filename, 'a') { |file| file.write("###command:#{command}###\n") file.write(value) } # File.close end