Class: Ruport::Graph
- Inherits:
-
Data::Table
- Object
- Data::Table
- Ruport::Graph
show all
- Defined in:
- lib/ruport/util/graph.rb
Defined Under Namespace
Classes: Line
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Graph
Returns a new instance of Graph.
33
34
35
|
# File 'lib/ruport/util/graph.rb', line 33
def initialize(options={})
super({:record_class => Line}.merge(options))
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(id, *args, &block) ⇒ Object
52
53
54
55
|
# File 'lib/ruport/util/graph.rb', line 52
def method_missing(id,*args,&block)
id.to_s =~ /^to_(.*)/
$1 ? as($1.to_sym,{:data => self}.merge(args[0]||{}),&block) : super
end
|
Instance Method Details
#add_line(row_data, options = {}) ⇒ Object
37
38
39
40
|
# File 'lib/ruport/util/graph.rb', line 37
def add_line(row_data,options={})
self << row_data
self[-1].name = options[:name]
end
|
#as(format, *args, &block) ⇒ Object
48
49
50
|
# File 'lib/ruport/util/graph.rb', line 48
def as(format,*args,&block)
Ruport::Renderer::Graph.render(format,*args,&block)
end
|
#dup ⇒ Object
42
43
44
45
46
|
# File 'lib/ruport/util/graph.rb', line 42
def dup
obj = self.class.new(:column_names => column_names)
data.each { |r| obj.add_line(r.to_a,:name => r.name)}
return obj
end
|