0
0
Fork 0

Started implementation of rubella

Dunno why there is no earlier commit...

Map class is probably a little bit too static. I will rewort this later, but
first we'll finish some of the other stuff.
This commit is contained in:
Stormwind 2015-02-17 22:03:32 +01:00
parent 4e7fc4bef5
commit d3531e8d2b
6 changed files with 108 additions and 0 deletions

55
lib/rubella.rb Normal file
View File

@ -0,0 +1,55 @@
module Rubella
class Map
def initialize(input, output, weighting)
case input
when "json" then
self.input_json
else
raise NotImplementedError, "Not supported input type "+input+" given"
end
case output
when "image" then
self.output_image
else
raise NotImplementedError, "Not supported output type "+output+" given"
end
case weighting
when "per_value" then
self.weighting_per_value
when "per_overall_load" then
self.weighting_per_overall_load
when "expotential" then
self.weighting_expotential
else
raise NotImplementedError, "Not supported weighting type "+weighting+" given"
end
end
def input_json
require "rubella/input/json"
end
def output_image
require "rubella/output/image"
end
def weighting_per_value
require "rubella/weighting/per_value"
end
def weighting_per_overall_load
require "rubella/weighting/per_overall_load"
end
def weighting_expotential
require "rubella/weighting/expotential"
end
end
end

29
lib/rubella/input/json.rb Normal file
View File

@ -0,0 +1,29 @@
require 'json'
module Rubella
module Input
#
#
class JSON
attr_reader :data
def initialize(json_string)
data = ::JSON::load(json_string)
end
def self.string(json_string)
self.new(json_string)
end
def self.file(json_file)
self.new File.new(json_file, 'r')
end
# private :new
end
end
end

View File

View File

View File

@ -0,0 +1,24 @@
module Rubella
module Weigthing
# Gets an input object and prepares the data for the output.
#
# This class weights the input data per value.
# Which means, that all values together make 100%. So you need all values at
# the same level, to get the maximum color intensity.
#
# The output is an Array which contains again an Array per every point of
# time, which contains the load in the given steps (default is 10% per step)
# and the value in percentage for the representative olor intensity.
#
class PerValue
def initialize
end
end
end
end