Class: Spicy::Disk::WordList
- Inherits:
-
Object
- Object
- Spicy::Disk::WordList
- Includes:
- Seek
- Defined in:
- lib/disk-corpus.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(file_name) ⇒ WordList
constructor
A new instance of WordList.
- #word(*args) ⇒ Object
Constructor Details
#initialize(file_name) ⇒ WordList
Returns a new instance of WordList.
24 25 26 27 28 29 30 |
# File 'lib/disk-corpus.rb', line 24 def initialize(file_name) @file = File.open(file_name, 'rb') @cumulative = Spicy::Header.cumulative(@file) @min = @cumulative.keys.min @max = @cumulative.keys.max @origin = @file.pos end |
Instance Method Details
#close ⇒ Object
32 33 34 |
# File 'lib/disk-corpus.rb', line 32 def close @file.close end |
#word(*args) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/disk-corpus.rb', line 36 def word(*args) seek(*args) do |index| @file.seek(@origin + index * @max, IO::SEEK_SET) @file.read(@max).strip end end |