Class: Smog
Instance Method Summary collapse
- #calc_score(sentence_count, with_three) ⇒ Object
- #name ⇒ Object
- #score(text, stats) ⇒ Object
- #three_syllables(syllables) ⇒ Object
Instance Method Details
#calc_score(sentence_count, with_three) ⇒ Object
16 17 18 |
# File 'lib/formulas/smog.rb', line 16 def calc_score(sentence_count, with_three) (1.043 * Math.sqrt(with_three * (30.0 / sentence_count)) + 3.1291).round(1) end |
#name ⇒ Object
20 21 22 |
# File 'lib/formulas/smog.rb', line 20 def name 'SMOG Index' end |
#score(text, stats) ⇒ Object
3 4 5 6 |
# File 'lib/formulas/smog.rb', line 3 def score(text, stats) with_three = three_syllables(text['syllables']) calc_score(stats['sentence_count'], with_three) end |
#three_syllables(syllables) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/formulas/smog.rb', line 8 def three_syllables(syllables) with_three = 0 syllables.each do |s| with_three += 1 if s > 2 end with_three end |