Class: MetricFu::FlayGrapher

Inherits:
Grapher
  • Object
show all
Defined in:
lib/graphs/flay_grapher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Grapher

require_gruff

Constructor Details

#initializeFlayGrapher

Returns a new instance of FlayGrapher.



8
9
10
11
12
# File 'lib/graphs/flay_grapher.rb', line 8

def initialize
  super
  self.flay_score = []
  self.labels = {}
end

Instance Attribute Details

#flay_scoreObject

Returns the value of attribute flay_score.



6
7
8
# File 'lib/graphs/flay_grapher.rb', line 6

def flay_score
  @flay_score
end

#labelsObject

Returns the value of attribute labels.



6
7
8
# File 'lib/graphs/flay_grapher.rb', line 6

def labels
  @labels
end

Instance Method Details

#get_metrics(metrics, date) ⇒ Object



14
15
16
17
# File 'lib/graphs/flay_grapher.rb', line 14

def get_metrics(metrics, date)
  self.flay_score.push(metrics[:flay][:total_score].to_i)
  self.labels.update( { self.labels.size => date })
end

#graph!Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/graphs/flay_grapher.rb', line 19

def graph!
  g = Gruff::Line.new(MetricFu.graph_size)
  g.title = "Flay: duplication"
  g.theme = MetricFu.graph_theme
  g.font = MetricFu.graph_font
  g.data('flay', self.flay_score)
  g.labels = self.labels
  g.title_font_size = MetricFu.graph_title_font_size
  g.legend_box_size = MetricFu.graph_legend_box_size
  g.legend_font_size = MetricFu.graph_legend_font_size
  g.marker_font_size = MetricFu.graph_marker_font_size
  g.write(File.join(MetricFu.output_directory, 'flay.png'))
end