Class: BigBench::PostProcessor::Graphs::LineGraph

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

Overview

Encapsules the gruff line graph

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of LineGraph.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bigbench/post_processor/graphs.rb', line 29

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

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



26
27
28
# File 'lib/bigbench/post_processor/graphs.rb', line 26

def graph
  @graph
end

#labelsObject

Returns the value of attribute labels.



27
28
29
# File 'lib/bigbench/post_processor/graphs.rb', line 27

def labels
  @labels
end

Instance Method Details

#add(title, x, y) ⇒ Object



43
44
45
46
# File 'lib/bigbench/post_processor/graphs.rb', line 43

def add title, x, y
  @x = x
  @graph.data(title, y)
end

#openObject



54
55
56
# File 'lib/bigbench/post_processor/graphs.rb', line 54

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

#write(file) ⇒ Object



48
49
50
51
52
# File 'lib/bigbench/post_processor/graphs.rb', line 48

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