0
0
Fork 0

Get Input data into weightin process

The data gets weighted.
I also fixed some tiny bugs.
This commit is contained in:
Stormwind 2015-02-18 22:45:02 +01:00
parent 3f49c255ea
commit 46a44ae9c2
2 changed files with 11 additions and 5 deletions

View File

@ -47,11 +47,16 @@ module Rubella
end
def create_from_string data
@input.string data
process @input.string data
end
def create_from_file file_name
@input.file file_name
process @input.file file_name
end
def process inpt
weight = @weighting.new 10
weight.parse inpt
end
def input_json

View File

@ -12,7 +12,8 @@ module Rubella
self.buckets = buckets
end
def parse(data)
def parse input
data = input.data
# no data, no work
return [] if data.length == 0
@ -29,7 +30,7 @@ module Rubella
data_list << Array.new(buckets) do
amount = cores.select { |core| core >= i and core < (i+@steps)}.length
i = i + @steps
amount/total_amount
amount.to_f/total_amount
end
end
@ -42,7 +43,7 @@ module Rubella
raise ArgumentError, "Amount of buckets must be 1, 2, 5, 10, 20 or 50"
end
@steps = buckets/100
@steps = 100/buckets
@buckets = buckets
end