Class: Automated_readability

Inherits:
Formula
  • Object
show all
Defined in:
lib/formulas/ari.rb

Instance Method Summary collapse

Instance Method Details

#calc_score(letter_count, word_count, sentence_count) ⇒ Object


7
8
9
# File 'lib/formulas/ari.rb', line 7

def calc_score(letter_count, word_count, sentence_count)
  (((4.71 * (letter_count.to_f / word_count.to_f)) + (0.5 * (word_count.to_f / sentence_count.to_f))) - 21.43).round(1)
end

#nameObject


11
12
13
# File 'lib/formulas/ari.rb', line 11

def name
  'Automated Readability Index'
end

#score(text, stats) ⇒ Object


3
4
5
# File 'lib/formulas/ari.rb', line 3

def score(text, stats)
  calc_score(stats['letter_count'], stats['word_count'], stats['sentence_count'])
end