Skip to content

cmaujean/rfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RFile

Travis build status:

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

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.

Usage

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

randomline

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

randomlines(num)

an array of random lines with num elements

line(line_number)

the specific line at line_number

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

Credits

Author:

Christopher Maujean <[email protected]>

Contributors:

Erik Hollensebe

About

a read only, line oriented, sparse file class

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages