Class: GithubChart::Chart

Inherits:
Object
  • Object
show all
Defined in:
lib/githubchart.rb,
lib/githubchart/svg.rb

Overview

Convert stats into SVG

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Chart

Create a new chart object Passes the username through to GithubStats Uses colors rather than default, if provided



58
59
60
61
62
63
# File 'lib/githubchart.rb', line 58

def initialize(params = {})
  params = { user: params } unless params.is_a? Hash
  @stats = params.fetch(:data) { GithubStats.new(params[:user]).data }
  @colors = params[:colors] || :default
  @colors = COLOR_SCHEMES[@colors] unless @colors.is_a? Array
end

Instance Attribute Details

#colorsObject

Returns the value of attribute colors



51
52
53
# File 'lib/githubchart.rb', line 51

def colors
  @colors
end

#statsObject (readonly)

Returns the value of attribute stats



50
51
52
# File 'lib/githubchart.rb', line 50

def stats
  @stats
end

Instance Method Details

#svgObject



14
15
16
17
18
19
20
21
22
# File 'lib/githubchart/svg.rb', line 14

def svg
  grid = matrix
  chart = SVGPlot.new(width: 13 * grid.column_size + 13,
                      height: 13 * grid.row_size + 13)
  svg_add_points grid, chart
  svg_add_weekdays chart
  svg_add_months chart
  chart.to_s
end