C0 code coverage information

Generated on Sun Sep 27 08:38:00 -0700 2009 with rcov 0.8.1.2


Code reported as executed by Ruby looks like
    this... and this: this line is also marked as
    covered. Lines considered as run by rcov, but
    not reported by Ruby, look like this, and
    this: these lines were inferred by rcov (using simple heuristics).
    Finally, here's a line marked as not
    executed. 
Name Total lines Lines of code Total coverage Code coverage
lib/interferoman/interferoman.rb 92 70
100.0%  
100.0%  
 1
    module Interferoman  2
    class Interferoman  3 def
    word_list=(list)  4 @list =
    {}  5  6 list.each do |word|  7 (@list[word.length] ||= []) <<
    word  8 end  9 end 10 11 def new_game(*) 12 @remaining_letters = [true]*26 13 @current_game_list = nil
    14 end 15 16 def guess(word, *) 17 initialize_or_filter_game_list(word) 18 19 guess =
    best_guess(get_letter_counts(@current_game_list)) 20 @remaining_letters[guess] = false
    21 22 (guess+?a).chr 23 end 24 25 def initialize_or_filter_game_list(word) 26 if @current_game_list.nil?
    27 @current_game_list =
    @list[word.length].dup 28 else 29 filter_word_list(word) 30 end 31 end 32 33 def filter_word_list(regexy) 34 rstring = regexy.tr('_', '.')
    35 regex =
    Regexp.new("^#{rstring}$") 36 @current_game_list.delete_if{|word| !regex.match(word)}
    37 end 38 39 def get_letter_counts(word_array) 40 counts = [0]*27 41 42 random_select(50, word_array).each{|word|
    add_letter_counts(counts, word)} 43 44
    filter_counts(counts) 45
    end 46 47 def random_select(size, array)
    48 r = array[0...size]
    49 50 size.upto(array.length - 1) do |i|
    51 pos = rand(i+1)
    52 if (pos < size)
    53 r[pos] = array[i]
    54 end 55 end 56 57 r 58 end 59 60
    def add_letter_counts(counts, word) 61 letters = word.scan(/./).uniq 62 letters.each{|l| counts[l[0] - ?a]
    += 1} 63 end
    64 65 def filter_counts(counts)
    66 counts.each_with_index
    do |count, i| 67 counts[i]
    = 0 unless @remaining_letters[i] 68 end 69 end 70 71
    def best_guess(counts) 72
    guess_index = -1 73
    74
    counts.each_with_index{|count, i| guess_index = i if counts[i] >
    counts[guess_index]} 75
    76 guess_index
    77 end 78 79 def incorrect_guess(guess) 80 @current_game_list.delete_if{|w|
    w.include?(guess.downcase)} 81 end 82 83
    def correct_guess(*) 84
    end 85 86 def fail(*) 87 end 88 89 def game_result(*) 90 end 91 end 92 end 

Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.

Valid XHTML 1.0! Valid CSS!