Module: TerminalVis::Output
- Defined in:
- lib/output/output.rb
Overview
This module takes care about the output in the terminal and serves several methods to create the desired output:
* visual output
* help output
Class Method Summary collapse
-
.check_data_range(data_indices) ⇒ Object
checks if the first argument of -d is less than 1.
-
.create_animation(meta_data) ⇒ Object
private
creates animated output of the whole data series depending on the animation parameter.
-
.create_delta_output(meta_data) ⇒ Object
creates output when using the parameter -d.
-
.create_interpolation_output(meta_data) ⇒ Object
creates output when using the parameter -c interpolation should be applied.
-
.create_output(meta_data) ⇒ Object
creates output based on MetaData::VisMetaData and parameters.
-
.create_range_output(meta_data) ⇒ Object
creates output when using the parameter -r.
-
.create_region_interpolation_output(meta_data) ⇒ Object
creates output when using the parameter -s.
-
.create_single_output_at_index(meta_data, index) ⇒ Object
private
creates default output or output with an index using -i.
-
.create_timeline(meta_data) ⇒ Object
creates a time line for the parameter -t.
-
.get_and_check_data(index, meta_data) ⇒ DataSet
private
checks if the returned data exists, nil means data access outside the boundaries of the data.
-
.get_data_for_indices(data_indices, meta_data) ⇒ Hash
private
method to check the datasets specified by the data indices and return the data.
-
.get_output_options ⇒ Hash
private
method to determine output options for the extreme values and the extended legend.
Class Method Details
.check_data_range(data_indices) ⇒ Object
checks if the first argument of -d is less than 1
171 172 173 174 175 |
# File 'lib/output/output.rb', line 171 def self.check_data_range(data_indices) if (data_indices[:first] < 0) raise IndexError, ' Error: first index of -d is less than 1'.red end end |
.create_animation(meta_data) ⇒ Object (private)
creates animated output of the whole data series depending on the animation parameter
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/output/output.rb', line 39 private_class_method def self.create_animation() data_series = TerminalVis.data_repo.repository[] animation_speed = Integer(TerminalVis.parameter_handler. repository.parameters[:all]) data_series.series.each_index { |index| create_single_output_at_index(, index) if (animation_speed > 0) sleep(animation_speed) else print 'press Enter to continue ...'.green # STDIN to read from console when providing parameters in ARGV STDIN.gets.chomp end } end |
.create_delta_output(meta_data) ⇒ Object
creates output when using the parameter -d
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/output/output.rb', line 58 def self.create_delta_output() data_indices = ParameterCollector::determine_indices_for_delta data = get_data_for_indices(data_indices, ) result = DatasetStatistics.subtract_datasets(data[:first_data], data[:second_data]) = if (![:auto_scale]) DataOutput::DeltaOutput.new(result, , data_indices, ) else DataOutput::ScaledDeltaOutput.new(result, , data_indices, ) end end |
.create_interpolation_output(meta_data) ⇒ Object
creates output when using the parameter -c interpolation should be applied
77 78 79 80 81 82 83 84 85 |
# File 'lib/output/output.rb', line 77 def self.create_interpolation_output() coordinates = ParameterCollector::determine_interpolation_values index = TerminalVis.get_and_check_index() value = TerminalVis::Interpolation. interpolate_for_coordinate(, coordinates, get_and_check_data(index, )) InterpolationOutput.new(value, index, coordinates, TerminalVis.data_repo.repository[]) end |
.create_output(meta_data) ⇒ Object
creates output based on MetaData::VisMetaData and parameters
25 26 27 28 29 30 31 32 33 |
# File 'lib/output/output.rb', line 25 def self.create_output() if (TerminalVis.parameter_handler.repository.parameters[:all]) create_animation() else index = TerminalVis.get_and_check_index() create_single_output_at_index(, index) end TerminalVis.data_repo.data_complete?() end |
.create_range_output(meta_data) ⇒ Object
creates output when using the parameter -r
105 106 107 108 109 110 111 |
# File 'lib/output/output.rb', line 105 def self.create_range_output() data_series = TerminalVis.data_repo.repository[] parameters = ParameterCollector::determine_range_parameters = RangeOutput.new(, data_series, parameters, ) end |
.create_region_interpolation_output(meta_data) ⇒ Object
creates output when using the parameter -s
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/output/output.rb', line 90 def self.create_region_interpolation_output() coordinates = ParameterCollector::determine_interpolation_values values = ParameterCollector::determine_region_parameters values[:index] = TerminalVis.get_and_check_index() values = values.merge() output = TerminalVis::Interpolation.region_interpolation(, get_and_check_data(values[:index], ), coordinates, values) DataOutput::RegionOutput.new(output, coordinates, TerminalVis.data_repo.repository[], values) end |
.create_single_output_at_index(meta_data, index) ⇒ Object (private)
creates default output or output with an index using -i
133 134 135 136 137 138 139 140 141 142 |
# File 'lib/output/output.rb', line 133 private_class_method def self.create_single_output_at_index(, index) = [:index] = index data_series = TerminalVis.data_repo.repository[] if (![:auto_scale]) DataOutput::SingleOutput.new(data_series, , ) else DataOutput::ScaledDatasetOutput.new(data_series, , ) end end |
.create_timeline(meta_data) ⇒ Object
creates a time line for the parameter -t
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/output/output.rb', line 116 def self.create_timeline() data_series = TerminalVis.data_repo.repository[] values = ParameterCollector::determine_timeline_values = if (![:auto_scale]) timeline = Timeline.new(, data_series, values) else timeline = TimelineScaling.new(, data_series, values) = timeline. end TimelineOutput.new(timeline.mapped_values, , values) end |
.get_and_check_data(index, meta_data) ⇒ DataSet (private)
checks if the returned data exists, nil means data access outside the boundaries of the data
184 185 186 187 188 189 190 191 |
# File 'lib/output/output.rb', line 184 private_class_method def self.get_and_check_data(index, ) data = TerminalVis.data_repo.repository[].series[index] if (data == nil) raise IndexError, " Error: argument #{index + 1} from -d is out of bounds".red end return data end |
.get_data_for_indices(data_indices, meta_data) ⇒ Hash (private)
method to check the datasets specified by the data indices and return the data
161 162 163 164 165 166 167 |
# File 'lib/output/output.rb', line 161 private_class_method def self.get_data_for_indices(data_indices, ) data = Hash.new() check_data_range(data_indices) data[:first_data] = get_and_check_data(data_indices[:first], ) data[:second_data] = get_and_check_data(data_indices[:second], ) return data end |
.get_output_options ⇒ Hash (private)
method to determine output options for the extreme values and the extended legend
147 148 149 150 151 152 153 154 |
# File 'lib/output/output.rb', line 147 private_class_method def self. { :extreme_values => TerminalVis.parameter_handler.repository.parameters[:extreme], :legend => TerminalVis.option_handler..repository[:legend_extend], :auto_scale => TerminalVis::option_handler..repository[:auto_scale] } end |