Class: MorningPages::TextReporter
- Inherits:
-
Struct
- Object
- Struct
- MorningPages::TextReporter
- Defined in:
- lib/morning-pages/text_reporter.rb
Instance Attribute Summary collapse
-
#stats ⇒ Object
Returns the value of attribute stats.
Instance Method Summary collapse
Instance Attribute Details
#stats ⇒ Object
Returns the value of attribute stats
2 3 4 |
# File 'lib/morning-pages/text_reporter.rb', line 2 def stats @stats end |
Instance Method Details
#average_word_length(stats) ⇒ Object
11 12 13 14 15 |
# File 'lib/morning-pages/text_reporter.rb', line 11 def average_word_length(stats) stats.count > 0 ? "Average word length: %.2f." % [ stats.average_length ] : "" end |
#report ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/morning-pages/text_reporter.rb', line 3 def report [ target(stats), "You have written #{stats.count} words today.", average_word_length(stats) ].join("\n") end |
#target(stats) ⇒ Object
17 18 19 20 21 |
# File 'lib/morning-pages/text_reporter.rb', line 17 def target(stats) stats.count >= MorningPages::TARGET ? "Congratulations! You have reached the target today -- you are awesome!" : "You have written %.2f%% of the target today." % [stats.count * 100.0 / TARGET] end |