Class RecordSearch::Search
In: lib/recordsearch/search.rb
Parent: Object

Methods

close   eq   gt   lt   new   parse   read   search  

Constants

INDEX_SIZE = 4   TODO is there a sizeof(long) ?

Public Class methods

Returns a new Search object. db is the file having the data used for your searches. db_idx is the index created with RecordSearch#index if it‘s nil, it will construct a filename appending ‘.idx’ to the value db has.

Public Instance methods

Close the files.

Searches object key in the file using binary search. If found returns what your implementation of parse returned, nil otherwise.

Protected Instance methods

Checks if two records are the same. This method raises an exception; you must implement it in your subclass to compare records according to your needs.

Compares two records read from the file and checks whether a is greater than b. This method raises an exception; you must implement it in your subclass to compare records according to your needs.

Compares two records read from the file and checks whether a is less than b. It‘s implemented using gt and eq.

Parse a record read from the file. This method raises an exception. You must implement this method to parse the file according to your needs.

Reads and parses the line at position index.

[Validate]