class Bable::Index::ColemanLiau

This class is responsible of calculating the Coleman-Liau Index. Check en.wikipedia.org/wiki/Coleman%E2%80%93Liau_index for knowing more.

Public Instance Methods

calc() click to toggle source
# File lib/bable/index/coleman_liau.rb, line 6
def calc
  (0.0588 * average_chars_per_100_words -
    0.296 * average_sentences_per_100_words - 15.8).round(2)
end

Private Instance Methods

average_chars_per_100_words() click to toggle source
# File lib/bable/index/coleman_liau.rb, line 13
def average_chars_per_100_words
  text.average_word_length * 100
end
average_sentences_per_100_words() click to toggle source
# File lib/bable/index/coleman_liau.rb, line 17
def average_sentences_per_100_words
  text.average_word_length * 100 / text.average_sentence_length
end