Class: BinarySearch::FileDataSource

Inherits:
DataSource show all
Defined in:
lib/binarysearch/data_source.rb

Instance Method Summary collapse

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

#closeObject



15
16
17
18
# File 'lib/binarysearch/data_source.rb', line 15

def close
  @file.close
  @file = nil
end

#nextObject



20
21
22
# File 'lib/binarysearch/data_source.rb', line 20

def next
  @file.gets
end