Home > rfile

rfile

Rfile is a project mainly written in Ruby, based on the BSD-3-Clause license.

a read only, line oriented, sparse file class

h1. RFile

"Travis":http://travis-ci.org build status: !https://secure.travis-ci.org/cmaujean/rfile.png!

A read only file class, providing random line based access to a large file without loading the whole file into memory.

h2. Synopsis

ARGH. It seems I can't embed a gist in my README, even though said gist and said README are on github.

So, until I can, the "synopsis is over here":https://gist.github.com/1315533.

h2. Usage

h3. new(path, recycle, sep_string)

@rfile = RFile.new('path/to/file', true, "\n")@

path: the path to an existing file

recycle: boolean value, if true the randomline method will reload the index (fast) when it runs out of unique lines to produce

sep_string: the string that determines what a line is, lines returned by the methods do not include the separator

h3. randomline

a random line from the file (or nil if no lines are left and recycle == false)

h3. randomlines(num)

an array of random lines with num elements

h3. line(line_number)

the specific line at line_number

h3. Also, the Enumerable module is mixed in, so you get a bunch of that stuff as well.

h2. Credits

h3. Author:

Christopher Maujean [email protected]

h3. Contributors:

"Erik Hollensebe":https://github.com/erikh