Class: SeqFile
- Inherits:
-
Object
- Object
- SeqFile
- Defined in:
- lib/seq_file.rb
Instance Method Summary collapse
- #close ⇒ Object
- #eof ⇒ Object
-
#initialize(filename = nil, read = true) ⇒ SeqFile
constructor
A new instance of SeqFile.
- #read ⇒ Object
- #write(val) ⇒ Object
Constructor Details
#initialize(filename = nil, read = true) ⇒ SeqFile
Returns a new instance of SeqFile.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/seq_file.rb', line 25 def initialize(filename = nil,read = true) if filename == nil filename = File.join(Rails.root, 'log', 'NoName-'+Time.now.localtime.strftime("%Y-%m-%d")+".log") end if read if FileTest::exist?(filename) @file = File.open(filename, 'r') else @file = File.open(filename, 'w+') end else @file = File.open(filename, 'a') end end |
Instance Method Details
#close ⇒ Object
54 55 56 |
# File 'lib/seq_file.rb', line 54 def close @file.close end |
#eof ⇒ Object
41 42 43 |
# File 'lib/seq_file.rb', line 41 def eof return @file.eof? end |
#read ⇒ Object
45 46 47 |
# File 'lib/seq_file.rb', line 45 def read return @file.gets.strip end |
#write(val) ⇒ Object
49 50 51 |
# File 'lib/seq_file.rb', line 49 def write(val) @file.puts val end |