class Chart
Public Class Methods
new(arry_times)
click to toggle source
# File lib/montecasting/chart.rb, line 7 def initialize(arry_times) @elements = arry_times end
Public Instance Methods
<=>(other_value)
click to toggle source
# File lib/montecasting/chart.rb, line 15 def <=>(other_value) self <=> other_value end
cumulative()
click to toggle source
# File lib/montecasting/chart.rb, line 31 def cumulative to_h.keys.to_chart {|index| to_h.values.take(index).inject(0) {|acc, elem| acc + elem}.percent_of(count).ceil(0)} end
each(&block)
click to toggle source
# File lib/montecasting/chart.rb, line 11 def each(&block) @elements.each(&block) end
group_by()
click to toggle source
# File lib/montecasting/chart.rb, line 23 def group_by to_h.to_chart(&:to_i) end
legend()
click to toggle source
# File lib/montecasting/chart.rb, line 19 def legend to_h.to_chart() end
percent_of()
click to toggle source
# File lib/montecasting/chart.rb, line 27 def percent_of to_h.to_chart {|value| value.percent_of(count).ceil(0)} end
to_h()
click to toggle source
# File lib/montecasting/chart.rb, line 36 def to_h uniq.sort.to_h {|s| [s, count{|elem| elem.equal? s}]} end