Class: GruffBuilder
- Inherits:
-
Object
- Object
- GruffBuilder
- Defined in:
- lib/gem_velocity/gruff_builder.rb
Constant Summary collapse
- MIN_VALUE =
0
- MAX_VALUE =
300
Instance Attribute Summary collapse
-
#gem_name ⇒ Object
Returns the value of attribute gem_name.
-
#hide_legend ⇒ Object
Returns the value of attribute hide_legend.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#line_datas ⇒ Object
Returns the value of attribute line_datas.
-
#max_value ⇒ Object
Returns the value of attribute max_value.
-
#min_value ⇒ Object
Returns the value of attribute min_value.
-
#relative_path ⇒ Object
Returns the value of attribute relative_path.
-
#root ⇒ Object
Returns the value of attribute root.
-
#title ⇒ Object
Returns the value of attribute title.
-
#versions ⇒ Object
Returns the value of attribute versions.
Instance Method Summary collapse
- #absolute_filename ⇒ Object
- #filename ⇒ Object
-
#initialize(root, relative_path, versions, gem_name, gruff_options = {}) ⇒ GruffBuilder
constructor
A new instance of GruffBuilder.
- #relative_filename ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(root, relative_path, versions, gem_name, gruff_options = {}) ⇒ GruffBuilder
Returns a new instance of GruffBuilder.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gem_velocity/gruff_builder.rb', line 16 def initialize(root, relative_path, versions, gem_name, = {}) # just pass it in all in gruff_options? @root = root || raise(ArgumentError,"you must set a root. default is root/public/images") @relative_path = relative_path || "public/images/" @versions = versions.is_a?(Array) ? versions : raise(ArgumentError,"versions must be an array") @gem_name = gem_name @title = [:title] || "" @labels = [:labels] || {} @line_datas = [:line_datas] @min_value = [:min_value] || MIN_VALUE @max_value = [:max_value] || MAX_VALUE @hide_legend = [:hide_legend] || false @type = [:type] end |
Instance Attribute Details
#gem_name ⇒ Object
Returns the value of attribute gem_name.
13 14 15 |
# File 'lib/gem_velocity/gruff_builder.rb', line 13 def gem_name @gem_name end |
#hide_legend ⇒ Object
Returns the value of attribute hide_legend.
14 15 16 |
# File 'lib/gem_velocity/gruff_builder.rb', line 14 def hide_legend @hide_legend end |
#labels ⇒ Object
Returns the value of attribute labels.
14 15 16 |
# File 'lib/gem_velocity/gruff_builder.rb', line 14 def labels @labels end |
#line_datas ⇒ Object
Returns the value of attribute line_datas.
14 15 16 |
# File 'lib/gem_velocity/gruff_builder.rb', line 14 def line_datas @line_datas end |
#max_value ⇒ Object
Returns the value of attribute max_value.
14 15 16 |
# File 'lib/gem_velocity/gruff_builder.rb', line 14 def max_value @max_value end |
#min_value ⇒ Object
Returns the value of attribute min_value.
14 15 16 |
# File 'lib/gem_velocity/gruff_builder.rb', line 14 def min_value @min_value end |
#relative_path ⇒ Object
Returns the value of attribute relative_path.
13 14 15 |
# File 'lib/gem_velocity/gruff_builder.rb', line 13 def relative_path @relative_path end |
#root ⇒ Object
Returns the value of attribute root.
13 14 15 |
# File 'lib/gem_velocity/gruff_builder.rb', line 13 def root @root end |
#title ⇒ Object
Returns the value of attribute title.
14 15 16 |
# File 'lib/gem_velocity/gruff_builder.rb', line 14 def title @title end |
#versions ⇒ Object
Returns the value of attribute versions.
13 14 15 |
# File 'lib/gem_velocity/gruff_builder.rb', line 13 def versions @versions end |
Instance Method Details
#absolute_filename ⇒ Object
39 40 41 |
# File 'lib/gem_velocity/gruff_builder.rb', line 39 def absolute_filename "#{absolute_destination}/#{filename}" end |
#filename ⇒ Object
35 36 37 |
# File 'lib/gem_velocity/gruff_builder.rb', line 35 def filename "#{graph_name(@type, versions.join("-"))}.png" end |
#relative_filename ⇒ Object
31 32 33 |
# File 'lib/gem_velocity/gruff_builder.rb', line 31 def relative_filename "#{@relative_path}#{filename}" end |
#write ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/gem_velocity/gruff_builder.rb', line 43 def write raise NoData if @line_datas.nil? || @line_datas.empty? ensure_destination gruff.title = @title gruff.labels = @labels @line_datas.each_with_index do |line_data,index| gruff.data graph_name(@versions[index]), line_data end gruff.minimum_value = @min_value gruff.maximum_value = @max_value gruff.hide_legend = @hide_legend gruff.write(absolute_filename) absolute_filename end |