Class: BigBench::PostProcessor::Graphs::PieGraph

Inherits:
Object
  • Object
show all
Defined in:
lib/bigbench/post_processor/graphs.rb

Overview

Encapsules the gruff pie graph

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, options = {}) ⇒ PieGraph

Returns a new instance of PieGraph.



75
76
77
78
79
80
81
82
# File 'lib/bigbench/post_processor/graphs.rb', line 75

def initialize title, options = {}
  @graph                = Gruff::Pie.new(options[:size] || DEFAULT[:size])
  @graph.title          = title
  @graph.theme          = options[:theme]               || DEFAULT[:theme]
  @folder               = options[:folder]              || DEFAULT[:folder]
  
  Dir.mkdir @folder unless File.directory?(@folder)
end

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



72
73
74
# File 'lib/bigbench/post_processor/graphs.rb', line 72

def graph
  @graph
end

#labelsObject

Returns the value of attribute labels.



73
74
75
# File 'lib/bigbench/post_processor/graphs.rb', line 73

def labels
  @labels
end

Instance Method Details

#add(title, percentage) ⇒ Object



84
85
86
# File 'lib/bigbench/post_processor/graphs.rb', line 84

def add title, percentage
  @graph.data(title, percentage)
end

#openObject



93
94
95
# File 'lib/bigbench/post_processor/graphs.rb', line 93

def open
  `open #{File.join(@folder, @file)}`
end

#write(file) ⇒ Object



88
89
90
91
# File 'lib/bigbench/post_processor/graphs.rb', line 88

def write file
  puts "Writing Graph to #{File.join(@folder, @file = file)}"
  @graph.write File.join(@folder, @file = file)
end