Class: Spicy::Memory::WordList
- Inherits:
-
Object
- Object
- Spicy::Memory::WordList
- Includes:
- Seek
- Defined in:
- lib/memory-corpus.rb
Instance Method Summary collapse
-
#initialize(file_name) ⇒ WordList
constructor
A new instance of WordList.
- #word(*args) ⇒ Object
- #words ⇒ Object
Constructor Details
#initialize(file_name) ⇒ WordList
Returns a new instance of WordList.
24 25 26 27 28 29 30 31 |
# File 'lib/memory-corpus.rb', line 24 def initialize(file_name) File.open(file_name, 'rb') do |r| @cumulative = Spicy::Header.cumulative(r) @min = @cumulative.keys.min @max = @cumulative.keys.max @words = r.read.split("\0") end end |
Instance Method Details
#word(*args) ⇒ Object
33 34 35 36 37 |
# File 'lib/memory-corpus.rb', line 33 def word(*args) seek(*args) do |index| @words[index] end end |
#words ⇒ Object
39 40 41 |
# File 'lib/memory-corpus.rb', line 39 def words @words end |