Class: Gruffy::Pie::PieSlice
- Inherits:
-
Struct
- Object
- Struct
- Gruffy::Pie::PieSlice
- Defined in:
- lib/gruffy/pie.rb
Overview
Helper Classes
Instance Attribute Summary collapse
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
- #color ⇒ Object
- #degrees ⇒ Object
- #label ⇒ Object
- #name ⇒ Object
- #percentage ⇒ Object
- #size ⇒ Object
- #value ⇒ Object
Instance Attribute Details
#total ⇒ Object
Returns the value of attribute total.
241 242 243 |
# File 'lib/gruffy/pie.rb', line 241 def total @total end |
Instance Method Details
#color ⇒ Object
251 252 253 |
# File 'lib/gruffy/pie.rb', line 251 def color data_array[2] end |
#degrees ⇒ Object
263 264 265 |
# File 'lib/gruffy/pie.rb', line 263 def degrees @degrees ||= size * 360.0 end |
#label ⇒ Object
267 268 269 |
# File 'lib/gruffy/pie.rb', line 267 def label [:show_values_as_labels] ? value.to_s : "#{percentage}%" end |
#name ⇒ Object
243 244 245 |
# File 'lib/gruffy/pie.rb', line 243 def name data_array[0] end |
#percentage ⇒ Object
259 260 261 |
# File 'lib/gruffy/pie.rb', line 259 def percentage @percentage ||= (size * 100.0).round end |
#size ⇒ Object
255 256 257 |
# File 'lib/gruffy/pie.rb', line 255 def size @size ||= value / total end |
#value ⇒ Object
247 248 249 |
# File 'lib/gruffy/pie.rb', line 247 def value data_array[1].first end |