Class: InterpolationOutput
- Inherits:
-
Object
- Object
- InterpolationOutput
- Defined in:
- lib/output/interpolation_output.rb
Overview
Output class to vizualize results issued within the scope of interpolation
Instance Attribute Summary collapse
-
#color_legend ⇒ ColorData
readonly
private
The color legend used for the dataset.
Instance Method Summary collapse
-
#create_colored_substrings(value) ⇒ String
private
method the visualize the values for the output.
-
#initialize(value, index, coordinates, data_series) ⇒ InterpolationOutput
constructor
initialization.
-
#print_boundary_line(point1, point2) ⇒ Object
private
method to print the line for two boundary points.
-
#print_interpolation_line(value) ⇒ Object
private
method to print the line with the interpolation value.
-
#print_result(value, boundary_points, data_series) ⇒ Object
private
method to print the colored result of the interpolation.
-
#print_times_blank(amount) ⇒ Object
private
method to print the required white spaces.
Constructor Details
#initialize(value, index, coordinates, data_series) ⇒ InterpolationOutput
initialization
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/output/interpolation_output.rb', line 18 def initialize(value, index, coordinates, data_series) boundary_points = TerminalVis::Interpolation::BilinearInterpolation. get_boundary_points(coordinates[:x], coordinates[:y]) print_result(value, boundary_points, data_series) puts "\nInterpolated value for coordinate (#{coordinates[:x]}, " \ "#{coordinates[:y]}) of dataset #{index} with result: " \ "#{value.round(3)}." end |
Instance Attribute Details
#color_legend ⇒ ColorData (readonly, private)
Returns the color legend used for the dataset.
31 32 33 |
# File 'lib/output/interpolation_output.rb', line 31 def color_legend @color_legend end |
Instance Method Details
#create_colored_substrings(value) ⇒ String (private)
method the visualize the values for the output
79 80 81 82 83 84 85 |
# File 'lib/output/interpolation_output.rb', line 79 def create_colored_substrings(value) if (value != nil) @color_legend.create_output_string_for(value, ' ') else print ' ' end end |
#print_boundary_line(point1, point2) ⇒ Object (private)
method to print the line for two boundary points
51 52 53 54 55 56 57 |
# File 'lib/output/interpolation_output.rb', line 51 def print_boundary_line(point1, point2) print_times_blank(4) print "#{create_colored_substrings(point1.value)}" print_times_blank(10) puts "#{create_colored_substrings(point2.value)}" nil end |
#print_interpolation_line(value) ⇒ Object (private)
method to print the line with the interpolation value
61 62 63 64 65 66 67 |
# File 'lib/output/interpolation_output.rb', line 61 def print_interpolation_line(value) print_times_blank(10) print "#{create_colored_substrings(value)}" print_times_blank(8) puts "(#{value.round(3)})" nil end |
#print_result(value, boundary_points, data_series) ⇒ Object (private)
method to print the colored result of the interpolation
39 40 41 42 43 44 45 46 |
# File 'lib/output/interpolation_output.rb', line 39 def print_result(value, boundary_points, data_series) @color_legend = ColorLegend::ColorData.new(data_series.min_value, data_series.max_value) print_boundary_line(boundary_points[:d_xy1], boundary_points[:d_x1y1]) print_interpolation_line(value) print_boundary_line(boundary_points[:d_xy], boundary_points[:d_x1y]) nil end |
#print_times_blank(amount) ⇒ Object (private)
method to print the required white spaces
71 72 73 74 |
# File 'lib/output/interpolation_output.rb', line 71 def print_times_blank(amount) amount.times { print ' '} nil end |