Module: Odyssey
- Defined in:
- lib/odyssey.rb,
lib/odyssey/engine.rb,
lib/odyssey/version.rb
Defined Under Namespace
Classes: Engine
Constant Summary collapse
- DEFAULT_FORMULA =
'Flesch_kincaid_RE'
- VERSION =
"0.1.8"
Class Method Summary collapse
-
.analyze(text, formula_name = DEFAULT_FORMULA, all_stats = false) ⇒ Object
main method.
- .ari(text, all_stats = false) ⇒ Object
- .coleman_liau(text, all_stats = false) ⇒ Object
- .flesch_kincaid_grade_level(text, all_stats = false) ⇒ Object
-
.flesch_kincaid_reading_ease(text, all_stats = false) ⇒ Object
pre-built methods that act as shortcuts to formulas #.
- .gunning_fog(text, all_stats = false) ⇒ Object
-
.method_missing(*args) ⇒ Object
run whatever method was given as if it were a shortcut to a formula.
- .smog(text, all_stats = false) ⇒ Object
-
.to_ary ⇒ Object
define this here, so it doesn’t get sent to method_missing().
Class Method Details
.analyze(text, formula_name = DEFAULT_FORMULA, all_stats = false) ⇒ Object
main method
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/odyssey.rb', line 8 def self.analyze(text, formula_name = DEFAULT_FORMULA, all_stats = false) #catch nils formula_name = DEFAULT_FORMULA if formula_name == nil @engine = Odyssey::Engine.new(formula_name) score = @engine.score(text) #return all stats? if all_stats output = @engine.get_stats else output = score end output end |
.ari(text, all_stats = false) ⇒ Object
66 67 68 |
# File 'lib/odyssey.rb', line 66 def self.ari(text, all_stats = false) analyze(text, 'Automated_readability', all_stats) end |
.coleman_liau(text, all_stats = false) ⇒ Object
58 59 60 |
# File 'lib/odyssey.rb', line 58 def self.coleman_liau(text, all_stats = false) analyze(text, 'Coleman_liau', all_stats) end |
.flesch_kincaid_grade_level(text, all_stats = false) ⇒ Object
50 51 52 |
# File 'lib/odyssey.rb', line 50 def self.flesch_kincaid_grade_level(text, all_stats = false) analyze(text, 'Flesch_kincaid_GL', all_stats) end |
.flesch_kincaid_reading_ease(text, all_stats = false) ⇒ Object
pre-built methods that act as shortcuts to formulas #
46 47 48 |
# File 'lib/odyssey.rb', line 46 def self.flesch_kincaid_reading_ease(text, all_stats = false) analyze(text, 'Flesch_kincaid_RE', all_stats) end |
.gunning_fog(text, all_stats = false) ⇒ Object
54 55 56 |
# File 'lib/odyssey.rb', line 54 def self.gunning_fog(text, all_stats = false) analyze(text, 'Gunning_fog', all_stats) end |
.method_missing(*args) ⇒ Object
run whatever method was given as if it were a shortcut to a formula
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/odyssey.rb', line 26 def self.method_missing(*args) method_string = args[0].to_s #capitalize the first letter first_letter = method_string[0].upcase method_string[0] = first_letter #send to the main method analyze(args[1], method_string, args[2] || false) end |
.smog(text, all_stats = false) ⇒ Object
62 63 64 |
# File 'lib/odyssey.rb', line 62 def self.smog(text, all_stats = false) analyze(text, 'Smog', all_stats) end |
.to_ary ⇒ Object
define this here, so it doesn’t get sent to method_missing()
38 39 40 |
# File 'lib/odyssey.rb', line 38 def self.to_ary [] end |