Class: DataFile2
- Inherits:
-
Object
- Object
- DataFile2
- Defined in:
- lib/Framework/DataFile2.rb
Instance Method Summary collapse
- #CheckCommands ⇒ Object
-
#initialize(filename) ⇒ DataFile2
constructor
A new instance of DataFile2.
- #Read(command) ⇒ Object
- #Write(command, value) ⇒ Object
Constructor Details
#initialize(filename) ⇒ DataFile2
Returns a new instance of DataFile2.
3 4 5 |
# File 'lib/Framework/DataFile2.rb', line 3 def initialize(filename) @filename = filename end |
Instance Method Details
#CheckCommands ⇒ Object
7 8 9 10 11 12 13 |
# 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) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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) ⇒ Object
15 16 17 18 19 20 21 |
# 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 |