Class: JekyllRecker::Generators::Stats
- Inherits:
-
Jekyll::Generator
- Object
- Jekyll::Generator
- JekyllRecker::Generators::Stats
- Defined in:
- lib/jekyll_recker/generators.rb
Overview
Stats Generator
Instance Attribute Summary collapse
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
Methods included from Math
Methods included from Logging
Methods included from Date
#calculate_streaks, #slice_by_consecutive, #time_to_date
Instance Attribute Details
#site ⇒ Object (readonly)
Returns the value of attribute site.
12 13 14 |
# File 'lib/jekyll_recker/generators.rb', line 12 def site @site end |
Instance Method Details
#generate(site) ⇒ Object
14 15 16 17 18 |
# File 'lib/jekyll_recker/generators.rb', line 14 def generate(site) @site = Site.new(site) info 'calculating statistics' site.data['stats'] = stats end |
#stats ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/jekyll_recker/generators.rb', line 20 def stats @stats ||= { 'total_words' => total(site.word_counts), 'average_words' => average(site.word_counts), 'total_posts' => site.entries.size, 'consecutive_posts' => calculate_streaks(site.dates).first['days'], 'swears' => calculate_swears } end |