class ArrayWordDataSource
Attributes
wordCounts[R]
Public Class Methods
new(wordList, offsetList, size)
click to toggle source
# File lib/data/word_data_source.rb, line 78 def initialize(wordList, offsetList, size) @wordList = wordList @offsetList = offsetList @size = size @wordCounts = createWordCounts end
Public Instance Methods
each_word(offset = 0) { |value| ... }
click to toggle source
# File lib/data/word_data_source.rb, line 100 def each_word(offset = 0) while ((value = self.valueAt(offset)) != nil) do yield value offset += 1 end end
valueAt(offset)
click to toggle source
# File lib/data/word_data_source.rb, line 85 def valueAt(offset) if (offset < @size) then return @wordList[@offsetList[offset]] else return nil end end
verify(word, count)
click to toggle source
# File lib/data/word_data_source.rb, line 93 def verify(word, count) if (@wordCounts == nil) then createWordCounts end @wordCounts[word] == count end
Private Instance Methods
createWordCounts()
click to toggle source
# File lib/data/word_data_source.rb, line 108 def createWordCounts() wordCounts = {} @wordList.each do |word| if (!wordCounts.has_key?(word)) then wordCounts[word] = 0 end wordCounts[word] += 1 end wordCounts end