Class: BinarySearch::FileDataSource
- Inherits:
-
DataSource
- Object
- DataSource
- BinarySearch::FileDataSource
- Defined in:
- lib/binarysearch/data_source.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(fname) ⇒ FileDataSource
constructor
A new instance of FileDataSource.
- #next ⇒ Object
Constructor Details
#initialize(fname) ⇒ FileDataSource
Returns a new instance of FileDataSource.
11 12 13 |
# File 'lib/binarysearch/data_source.rb', line 11 def initialize(fname) @file = File.open(fname, 'r') end |
Instance Method Details
#close ⇒ Object
15 16 17 18 |
# File 'lib/binarysearch/data_source.rb', line 15 def close @file.close @file = nil end |
#next ⇒ Object
20 21 22 |
# File 'lib/binarysearch/data_source.rb', line 20 def next @file.gets end |