Class: ColorLegend::ColorData
- Inherits:
-
BaseLegend
- Object
- BaseLegend
- ColorLegend::ColorData
- Defined in:
- lib/graphics/color_data.rb
Overview
Class to color output field according to color in BaseLegend#value_legend attributes (see Base). This class should be used when visualizing a dataset.
Instance Attribute Summary
Attributes inherited from BaseLegend
#delta, #max_value, #min_value, #value_legend
Instance Method Summary collapse
-
#create_output_string_for(value, out_str) ⇒ String
creates output string for given value.
-
#initialize(min_value, max_value) ⇒ ColorData
constructor
initialization with constraint: max_value > min_value.
Methods inherited from BaseLegend
#create_color_legend, #print_color_legend, #print_interval_values
Constructor Details
#initialize(min_value, max_value) ⇒ ColorData
initialization with constraint: max_value > min_value
16 17 18 19 20 21 22 23 24 |
# File 'lib/graphics/color_data.rb', line 16 def initialize(min_value, max_value) if (max_value <= min_value) raise ArgumentError, " Error in ColorLegend: max_value <= min_value\n".red end super create_color_legend(12) end |
Instance Method Details
#create_output_string_for(value, out_str) ⇒ String
creates output string for given value
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/graphics/color_data.rb', line 30 def create_output_string_for(value, out_str) return out_str.blue_bg if (value <= @value_legend[0]) return out_str.cyan_bg if (value <= @value_legend[1]) return out_str.light_blue_bg if (value <= @value_legend[2]) return out_str.light_cyan_bg if (value <= @value_legend[3]) return out_str.green_bg if (value <= @value_legend[4]) return out_str.light_green_bg if (value <= @value_legend[5]) return out_str.light_yellow_bg if (value <= @value_legend[6]) return out_str.yellow_bg if (value <= @value_legend[7]) return out_str.light_red_bg if (value <= @value_legend[8]) return out_str.red_bg if (value <= @value_legend[9]) return out_str.light_magenta_bg if (value <= @value_legend[10]) out_str.magenta_bg end |