Class: FileDataSource

Inherits:
BaseDataSource show all
Defined in:
lib/data/file_data_source.rb

Instance Attribute Summary

Attributes inherited from BaseDataSource

#startOffset

Instance Method Summary collapse

Methods inherited from BaseDataSource

#each_with_index, #extendWith, #has_terminator?, #nextDataSourceValueAt, #valueSequence

Constructor Details

#initialize(path) ⇒ FileDataSource

Returns a new instance of FileDataSource.



4
5
6
7
8
# File 'lib/data/file_data_source.rb', line 4

def initialize(path)
  @inFile = File.open(path, "rb")
  @checkFile = File.open(path, "rb")
  super(0)
end

Instance Method Details

#toString(startOffset, endOffset) ⇒ Object

substring



20
21
22
23
24
25
26
27
# File 'lib/data/file_data_source.rb', line 20

def toString(startOffset, endOffset)
  @checkFile.seek(startOffset - @startOffset, IO::SEEK_SET)
  if (endOffset >= startOffset) then
    return @checkFile.read(endOffset - startOffset + 1)
  else
    return @checkFile.read()
  end
end

#valueAt(offset) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/data/file_data_source.rb', line 10

def valueAt(offset)
  @checkFile.seek(offset - @startOffset, IO::SEEK_SET)
  result = @checkFile.getc
  if (result == nil) then
    return self.nextDataSourceValueAt(offset)
  end
  result
end