Class: Igs::PieChart
- Inherits:
-
Object
- Object
- Igs::PieChart
- Defined in:
- lib/igs_pie_chart/pie_chart.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#endomargin ⇒ Object
readonly
Returns the value of attribute endomargin.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#target_element ⇒ Object
readonly
Returns the value of attribute target_element.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #height=(height) ⇒ Object
- #initialize(title, size, endomargin = 0, target_element = 'body', data) ⇒ PieChart constructor
- #labels ⇒ Object
- #render ⇒ Object
- #script ⇒ Object
- #style ⇒ Object
- #to_s ⇒ Object
- #width=(width) ⇒ Object
Constructor Details
#initialize(title, size, endomargin = 0, target_element = 'body', data) ⇒ PieChart
4 5 6 7 8 9 10 11 12 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 4 def initialize(title,size,endomargin=0,target_element='body',data) @title = title @size = size @endomargin = endomargin @data = data.values @labels = data.keys @target_element = target_element @default_attribution=false end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
2 3 4 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 2 def data @data end |
#endomargin ⇒ Object (readonly)
Returns the value of attribute endomargin.
2 3 4 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 2 def endomargin @endomargin end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
2 3 4 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 2 def size @size end |
#target_element ⇒ Object (readonly)
Returns the value of attribute target_element.
2 3 4 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 2 def target_element @target_element end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
2 3 4 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 2 def title @title end |
Instance Method Details
#height=(height) ⇒ Object
75 76 77 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 75 def height=(height) @height = height end |
#labels ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 40 def labels begin default_attribution path = File.("../../../templates/_labels.html.erb", __FILE__) output = ERB.new(File.read(path)).result(binding) rescue Exception => e STDERR.puts "Erro ao renderizar Labels! #{e}" output = nil end return output end |
#render ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 53 def render rendering = '<style>' rendering+= self.style rendering+= '</style>' rendering+= self.script rendering+= self.labels return rendering end |
#script ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 14 def script begin default_attribution path = File.("../../../templates/_script.html.erb", __FILE__) output = ERB.new(File.read(path)).result(binding) rescue Exception => e STDERR.puts "Erro ao renderizar JavaScript! #{e}" output = nil end return output end |
#style ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 27 def style begin default_attribution path = File.("../../../templates/_style.css.erb", __FILE__) output = ERB.new(File.read(path)).result(binding) rescue Exception => e STDERR.puts "Erro ao renderizar CSS! #{e}" output = nil end return output end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 63 def to_s render end |
#width=(width) ⇒ Object
71 72 73 |
# File 'lib/igs_pie_chart/pie_chart.rb', line 71 def width=(width) @width = width end |