Class: Gruff::Pie::PieSlice

Inherits:
Struct
  • Object
show all
Defined in:
lib/gruff/pie.rb

Overview

Helper Classes

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#totalObject

Returns the value of attribute total.



241
242
243
# File 'lib/gruff/pie.rb', line 241

def total
  @total
end

Instance Method Details

#colorObject



251
252
253
# File 'lib/gruff/pie.rb', line 251

def color
  data_array[2]
end

#degreesObject



263
264
265
# File 'lib/gruff/pie.rb', line 263

def degrees
  @degrees ||= size * 360.0
end

#labelObject



267
268
269
# File 'lib/gruff/pie.rb', line 267

def label
  options[:show_values_as_labels] ? value.to_s : "#{percentage}%"
end

#nameObject



243
244
245
# File 'lib/gruff/pie.rb', line 243

def name
  data_array[0]
end

#percentageObject



259
260
261
# File 'lib/gruff/pie.rb', line 259

def percentage
  @percentage ||= (size * 100.0).round
end

#sizeObject



255
256
257
# File 'lib/gruff/pie.rb', line 255

def size
  @size ||= value / total
end

#valueObject



247
248
249
# File 'lib/gruff/pie.rb', line 247

def value
  data_array[1].first
end