class Rubella::Weighting::PerCount
The Rubella::Weighting::PerCount
create a field of each given value. The weighting is based on the maximum value.
Public Class Methods
new(buckets = 7)
click to toggle source
Constructor Creates a new Rubella::Weighting::PerCount
object.
@param buckets int @return Rubella::Weighting::Base
@raise ArgumentError
Calls superclass method
Rubella::Weighting::Base::new
# File lib/rubella/weighting/per_count.rb, line 18 def initialize buckets = 7 super buckets end
Public Instance Methods
buckets=(buckets)
click to toggle source
Sets the buckets
@param buckets int The amount of buckets @raise ArgumentError
# File lib/rubella/weighting/per_count.rb, line 27 def buckets= buckets @buckets = buckets end
parse(input)
click to toggle source
Creates a output readable list. This list is Array within a subarrays, which contain the buckets for every time value unit.
@param input Rubella::Input
An input object @return Rubella::Storage
# File lib/rubella/weighting/per_count.rb, line 37 def parse input # prepare data data_list = Array.new() # Get the maximum of commits max = input.sort.pop i = 0 input.each do |commits| data_list << Array.new() if i == 0 data_list.last << commits.to_f/max if i == (buckets-1) i = 0 else i = i + 1 end end Rubella::Storage.new data_list end