Class: RecordSearch::FileDataSource
- Inherits:
-
DataSource
- Object
- DataSource
- RecordSearch::FileDataSource
- Defined in:
- lib/recordsearch/data_source.rb
Overview
A DataSource which reads from a text file.
Instance Method Summary collapse
-
#close ⇒ Object
Closes the file.
-
#initialize(fname) ⇒ FileDataSource
constructor
Creates a new FileDataSource using the value of fname as the file name.
-
#next ⇒ Object
Reads the next line.
Constructor Details
#initialize(fname) ⇒ FileDataSource
Creates a new FileDataSource using the value of fname as the file name.
16 17 18 |
# File 'lib/recordsearch/data_source.rb', line 16 def initialize(fname) @file = File.open(fname, 'r') end |
Instance Method Details
#close ⇒ Object
Closes the file.
21 22 23 24 |
# File 'lib/recordsearch/data_source.rb', line 21 def close @file.close @file = nil end |
#next ⇒ Object
Reads the next line.
27 28 29 |
# File 'lib/recordsearch/data_source.rb', line 27 def next @file.gets end |