Class: JekyllRecker::Graphs::Swears

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/jekyll_recker/graphs.rb

Overview

Swears Chart

Instance Attribute Summary

Attributes included from Base

#site

Instance Method Summary collapse

Methods included from Base

#graphs_join

Constructor Details

#initialize(site) ⇒ Swears

Returns a new instance of Swears.



69
70
71
72
# File 'lib/jekyll_recker/graphs.rb', line 69

def initialize(site)
  @data_dir = site.data_dir
  @graphs_dir = site.graphs_dir
end

Instance Method Details

#resultsObject



74
75
76
77
78
79
# File 'lib/jekyll_recker/graphs.rb', line 74

def results
  path = File.join(@data_dir, 'stats.json')
  data = JSON.parse(File.read(path))['swears']
  data.delete('total')
  data
end

#writeObject



81
82
83
84
85
86
87
88
89
# File 'lib/jekyll_recker/graphs.rb', line 81

def write
  g = ::Gruff::Pie.new('800x600')
  g.theme = Gruff::Themes::PASTEL
  g.hide_legend = false
  g.legend_at_bottom = true
  g.minimum_value = 0
  results.each { |w, n| g.data w, n }
  g.write(graphs_join('swears.png'))
end