Class: JekyllRecker::Graphs::Swears
- Inherits:
-
Object
- Object
- JekyllRecker::Graphs::Swears
- Includes:
- Base
- Defined in:
- lib/jekyll_recker/graphs.rb
Overview
Swears Chart
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
-
#initialize(site) ⇒ Swears
constructor
A new instance of Swears.
- #results ⇒ Object
- #write ⇒ Object
Methods included from Base
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
#results ⇒ Object
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 |
#write ⇒ Object
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 |