Class: MetricFu::Graph
- Inherits:
-
Object
- Object
- MetricFu::Graph
- Defined in:
- lib/base/graph.rb
Instance Attribute Summary collapse
-
#clazz ⇒ Object
Returns the value of attribute clazz.
Instance Method Summary collapse
- #add(graph_type) ⇒ Object
- #generate ⇒ Object
-
#initialize ⇒ Graph
constructor
A new instance of Graph.
Constructor Details
#initialize ⇒ Graph
Returns a new instance of Graph.
11 12 13 |
# File 'lib/base/graph.rb', line 11 def initialize self.clazz = [] end |
Instance Attribute Details
#clazz ⇒ Object
Returns the value of attribute clazz.
9 10 11 |
# File 'lib/base/graph.rb', line 9 def clazz @clazz end |
Instance Method Details
#add(graph_type) ⇒ Object
15 16 17 18 |
# File 'lib/base/graph.rb', line 15 def add(graph_type) grapher_name = graph_type.to_s.capitalize + "Grapher" self.clazz.push MetricFu.const_get(grapher_name).new end |
#generate ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/base/graph.rb', line 21 def generate return if self.clazz.empty? puts "Generating graphs" Dir[File.join(MetricFu.data_directory, '*.yml')].sort.each do |metric_file| puts "Generating graphs for #{metric_file}" date = metric_file.split('/')[3].split('.')[0] metrics = YAML::load(File.open(metric_file)) self.clazz.each do |grapher| grapher.get_metrics(metrics, date) end end self.clazz.each do |grapher| grapher.graph! end end |