2015-02-17 22:03:32 +01:00
|
|
|
module Rubella
|
|
|
|
|
|
|
|
class Map
|
2015-02-17 22:28:31 +01:00
|
|
|
attr_reader :input
|
|
|
|
attr_reader :output
|
|
|
|
attr_reader :weighting
|
2015-02-17 22:03:32 +01:00
|
|
|
|
2015-02-17 22:28:31 +01:00
|
|
|
def initialize(input_name, output_name, weighting_name)
|
2015-02-17 22:03:32 +01:00
|
|
|
|
2015-02-17 23:01:49 +01:00
|
|
|
# set the input type
|
2015-02-17 22:28:31 +01:00
|
|
|
@input = case input_name
|
2015-02-17 23:01:49 +01:00
|
|
|
# add the option to set input later
|
|
|
|
when nil then
|
|
|
|
nil
|
2015-02-17 22:03:32 +01:00
|
|
|
when "json" then
|
|
|
|
self.input_json
|
|
|
|
else
|
2015-02-17 22:28:31 +01:00
|
|
|
raise NotImplementedError, "Not supported input type "+input_name+" given"
|
2015-02-17 22:03:32 +01:00
|
|
|
end
|
|
|
|
|
2015-02-17 23:01:49 +01:00
|
|
|
# set the output type
|
2015-02-17 22:28:31 +01:00
|
|
|
@output = case output_name
|
2015-02-17 23:01:49 +01:00
|
|
|
# add the option to set the output later
|
|
|
|
when nil then
|
|
|
|
nil
|
2015-02-17 22:03:32 +01:00
|
|
|
when "image" then
|
|
|
|
self.output_image
|
|
|
|
else
|
2015-02-17 22:28:31 +01:00
|
|
|
raise NotImplementedError, "Not supported output type "+output_name+" given"
|
2015-02-17 22:03:32 +01:00
|
|
|
end
|
|
|
|
|
2015-02-17 23:01:49 +01:00
|
|
|
# set the weighting
|
2015-02-17 22:28:31 +01:00
|
|
|
@weighting = case weighting_name
|
2015-02-17 23:01:49 +01:00
|
|
|
# add the option to set the weighting later
|
|
|
|
when nil then
|
|
|
|
nil
|
2015-02-17 22:03:32 +01:00
|
|
|
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
|
2015-02-17 22:28:31 +01:00
|
|
|
raise NotImplementedError, "Not supported weighting type "+weighting_name+" given"
|
2015-02-17 22:03:32 +01:00
|
|
|
end
|
2015-02-17 22:28:31 +01:00
|
|
|
|
2015-02-17 22:03:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def input_json
|
|
|
|
require "rubella/input/json"
|
2015-02-17 22:28:31 +01:00
|
|
|
Input::JSON
|
2015-02-17 22:03:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def output_image
|
|
|
|
require "rubella/output/image"
|
2015-02-17 22:28:31 +01:00
|
|
|
Output::Image
|
2015-02-17 22:03:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def weighting_per_value
|
|
|
|
require "rubella/weighting/per_value"
|
2015-02-17 22:28:31 +01:00
|
|
|
Weighting::PerValue
|
2015-02-17 22:03:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def weighting_per_overall_load
|
|
|
|
require "rubella/weighting/per_overall_load"
|
2015-02-17 22:28:31 +01:00
|
|
|
Weighting::PerOverallLoad
|
2015-02-17 22:03:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def weighting_expotential
|
|
|
|
require "rubella/weighting/expotential"
|
2015-02-17 22:28:31 +01:00
|
|
|
Weighting::Expotential
|
2015-02-17 22:03:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|