Class: RecordSearch::FileDataSource

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

Overview

A DataSource which reads from a text file.

Instance Method Summary collapse

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

#closeObject

Closes the file.



21
22
23
24
# File 'lib/recordsearch/data_source.rb', line 21

def close
  @file.close
  @file = nil
end

#nextObject

Reads the next line.



27
28
29
# File 'lib/recordsearch/data_source.rb', line 27

def next
  @file.gets
end