Make interface for weighting input smaller
The input object must now only respond to each and must contain arrays.
This commit is contained in:
parent
9a013f53fd
commit
f561b2c769
|
@ -20,7 +20,7 @@ module Rubella
|
|||
# @return Rubella::Weighting::Base
|
||||
# @raise ArgumentError
|
||||
#
|
||||
def initialize(buckets = 10)
|
||||
def initialize buckets = 10
|
||||
self.buckets = buckets
|
||||
end
|
||||
|
||||
|
@ -31,7 +31,7 @@ module Rubella
|
|||
#
|
||||
def buckets= buckets
|
||||
# Must be divideable by 100
|
||||
if([1, 2, 5, 10, 20, 50].index(buckets) == nil)
|
||||
if [1, 2, 5, 10, 20, 50].index(buckets) == nil
|
||||
raise ArgumentError.new "Amount of buckets must be 1, 2, 5, 10, 20 "+
|
||||
"or 50"
|
||||
end
|
||||
|
|
|
@ -17,18 +17,13 @@ module Rubella
|
|||
# @param input Rubella::Input An input object
|
||||
# @return Rubella::Storage
|
||||
def parse input
|
||||
data = input.data
|
||||
# no data, no work
|
||||
return [] if data.length == 0
|
||||
|
||||
# total amount of cores
|
||||
total_amount = data[0].length
|
||||
|
||||
# prepare data
|
||||
data_list = Array.new()
|
||||
bucket_no = 0
|
||||
data_list = Array.new()
|
||||
bucket_no = 0
|
||||
total_amount = nil
|
||||
|
||||
data.each do |cores|
|
||||
input.each do |cores|
|
||||
total_amount = cores.length if total_amount.nil?
|
||||
# every 10 load percent one heatpoint
|
||||
i = 0
|
||||
data_list << Array.new(buckets) do
|
||||
|
|
|
@ -18,14 +18,10 @@ module Rubella
|
|||
# @param input Rubella::Input An input object
|
||||
# @return Rubella::Storage
|
||||
def parse input
|
||||
data = input.data
|
||||
# no data, no work
|
||||
return [] if data.length == 0
|
||||
|
||||
# prepare data
|
||||
data_list = Array.new()
|
||||
|
||||
data.each do |cores|
|
||||
input.each do |cores|
|
||||
|
||||
# Add all loads to compute how much % is one % load
|
||||
load_sum = 0
|
||||
|
|
|
@ -4,7 +4,7 @@ module Rubella
|
|||
module Weighting
|
||||
|
||||
# The Rubella::Weighting::PerValue object weights every bucket set to 1 in
|
||||
# ammount. So if you have have for example four cores, every core is
|
||||
# amount. So if you have have for example four cores, every core is
|
||||
# weighted to 0.25 no matter how much the load of a single core is. It's
|
||||
# just a "as is" weighting.
|
||||
#
|
||||
|
@ -17,17 +17,12 @@ module Rubella
|
|||
# @param input Rubella::Input An input object
|
||||
# @return Rubella::Storage
|
||||
def parse input
|
||||
data = input.data
|
||||
# no data, no work
|
||||
return [] if data.length == 0
|
||||
|
||||
# total amount of cores
|
||||
total_amount = data[0].length
|
||||
|
||||
# prepare data
|
||||
data_list = Array.new()
|
||||
total_amount = nil
|
||||
|
||||
data.each do |cores|
|
||||
input.each do |cores|
|
||||
total_amount = cores.length if total_amount.nil?
|
||||
# every 10 load percent one heatpoint
|
||||
i = 0
|
||||
data_list << Array.new(buckets) do
|
||||
|
|
Loading…
Reference in New Issue