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



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

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

Instance Attribute Details

#colorsObject

Returns the value of attribute colors.



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

def colors
  @colors
end

#statsObject (readonly)

Returns the value of attribute stats.



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

def stats
  @stats
end

Instance Method Details

#render(type) ⇒ Object

Raises:

  • (NameError)


66
67
68
69
# File 'lib/githubchart.rb', line 66

def render(type)
  raise(NameError, "Format #{type} is unsupported.") unless GithubChart.supports? type
  send("render_#{type}".to_sym)
end