Class: Lunar::Scoring

Inherits:
Object
  • Object
show all
Defined in:
lib/lunar/scoring.rb

Overview

of a given text.

Instance Method Summary collapse

Constructor Details

#initialize(words) ⇒ Scoring

Returns a new instance of Scoring.



5
6
7
# File 'lib/lunar/scoring.rb', line 5

def initialize(words)
  @words = Words.new(words)
end

Instance Method Details

#scoresObject



9
10
11
# File 'lib/lunar/scoring.rb', line 9

def scores
  @words.inject(Hash.new(0)) { |a, w| a[w.downcase] += 1 and a }
end