Class: Swoop::ChartRenderer

Inherits:
Renderer show all
Defined in:
lib/swoop/renderer/chart_renderer.rb

Instance Attribute Summary collapse

Attributes inherited from Renderer

#reports, #title

Instance Method Summary collapse

Constructor Details

#initialize(reports, title, filename = "index.html") ⇒ ChartRenderer

Returns a new instance of ChartRenderer.



9
10
11
12
# File 'lib/swoop/renderer/chart_renderer.rb', line 9

def initialize(reports, title, filename = "index.html")
  super(reports, title)
  @filename = filename
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



7
8
9
# File 'lib/swoop/renderer/chart_renderer.rb', line 7

def filename
  @filename
end

Instance Method Details

#class_count_dataObject



14
15
16
17
18
19
# File 'lib/swoop/renderer/chart_renderer.rb', line 14

def class_count_data
  rows = []
  rows << ['Date', 'Swift Class', 'Objective-C Class']
  rows += reports.map { |r| [ "#{r.name}\n(#{r.date})", r.swift_classes_count, r.objc_classes_count]  }
  rows.to_s
end

#class_percentage_dataObject



21
22
23
24
25
26
# File 'lib/swoop/renderer/chart_renderer.rb', line 21

def class_percentage_data
  rows = []
  rows << ['Date', 'Swift Class (%)', 'Objective-C Class (%)']
  rows += reports.map { |r| [ "#{r.name}\n(#{r.date})", r.swift_classes_percentage, r.objc_classes_percentage]  }
  rows.to_s
end

#renderObject



28
29
30
31
32
# File 'lib/swoop/renderer/chart_renderer.rb', line 28

def render
  empty_target_dir
  html_path = render_html
  `open #{html_path}`
end