Module: TerminalVis::ParameterCollector
- Defined in:
- lib/output/parameter_collector.rb
Overview
This module holds methods who are collecting the required parameters for a specific output format. They collect them from the corresponding repositories and return them.
Class Method Summary collapse
-
.create_error_message(parameter, type) ⇒ Object
private
method to create an error message when rescuing an error.
-
.determine_indices_for_delta ⇒ Hash
gets the indices of the data sets which should be substracted.
-
.determine_interpolation_values ⇒ Object
method to get the required coordinates to start an interpolation.
-
.determine_range_parameters ⇒ Hash
method to determine the required parameters for the paramater -r.
-
.determine_region_parameters ⇒ Hash
method to get the required values to create a region that will be interpolated.
-
.determine_timeline_values ⇒ Hash
method to get the required values to generate timeline output.
-
.read_parameter(parameter, index) ⇒ String
private
method to read the value for a given parameter and index.
-
.retrieve_float_parameters(first, second, parameter) ⇒ Hash
private
method to retrive the parameters for float values.
-
.retrieve_integer_parameters(first, second, parameter) ⇒ Hash
private
method to retrive the parameters for interger values.
-
.retrieve_parameters(first, second, parameter, type) ⇒ Hash
private
method to retrive the parameters for the given type.
Class Method Details
.create_error_message(parameter, type) ⇒ Object (private)
method to create an error message when rescuing an error
108 109 110 111 112 |
# File 'lib/output/parameter_collector.rb', line 108 private_class_method def self.(parameter, type) = " Error: at least one argument of #{parameter}" \ " is not a valid #{type}".red TerminalVis::print_error() end |
.determine_indices_for_delta ⇒ Hash
gets the indices of the data sets which should be substracted
29 30 31 32 33 34 |
# File 'lib/output/parameter_collector.rb', line 29 def self.determine_indices_for_delta data_indices = retrieve_parameters(:first, :second, :delta, 'Integer') data_indices[:first] -= 1 data_indices[:second] -= 1 return data_indices end |
.determine_interpolation_values ⇒ Object
method to get the required coordinates to start an interpolation
23 24 25 |
# File 'lib/output/parameter_collector.rb', line 23 def self.determine_interpolation_values retrieve_parameters(:x, :y, :coord, 'Float') end |
.determine_range_parameters ⇒ Hash
method to determine the required parameters for the paramater -r
38 39 40 41 42 43 44 45 |
# File 'lib/output/parameter_collector.rb', line 38 def self.determine_range_parameters parameters = retrieve_parameters(:lower, :upper, :range, 'Integer') parameters[:lower] -= 1 parameters[:upper] -= 1 parameters[:all] = TerminalVis.parameter_handler. repository.parameters[:all] return parameters end |
.determine_region_parameters ⇒ Hash
method to get the required values to create a region that will be interpolated
50 51 52 53 54 |
# File 'lib/output/parameter_collector.rb', line 50 def self.determine_region_parameters parameters = retrieve_parameters(:inter, :delta, :section, 'Float') { :inter_x => parameters[:inter], :delta_x => parameters[:delta], :inter_y => parameters[:inter], :delta_y => parameters[:delta]} end |
.determine_timeline_values ⇒ Hash
method to get the required values to generate timeline output
15 16 17 18 19 20 |
# File 'lib/output/parameter_collector.rb', line 15 def self.determine_timeline_values values = retrieve_parameters(:x, :y, :time, 'Float') values[:y_size] = TerminalVis.option_handler.. repository[:y_time_size] return values end |
.read_parameter(parameter, index) ⇒ String (private)
method to read the value for a given parameter and index
101 102 103 |
# File 'lib/output/parameter_collector.rb', line 101 private_class_method def self.read_parameter(parameter, index) TerminalVis.parameter_handler.repository.parameters[parameter][index] end |
.retrieve_float_parameters(first, second, parameter) ⇒ Hash (private)
method to retrive the parameters for float values
92 93 94 95 |
# File 'lib/output/parameter_collector.rb', line 92 private_class_method def self.retrieve_float_parameters(first, second, parameter) {first => Float(read_parameter(parameter, 0)), second => Float(read_parameter(parameter, 1))} end |
.retrieve_integer_parameters(first, second, parameter) ⇒ Hash (private)
method to retrive the parameters for interger values
82 83 84 85 |
# File 'lib/output/parameter_collector.rb', line 82 private_class_method def self.retrieve_integer_parameters(first, second, parameter) {first => Integer(read_parameter(parameter, 0)), second => Integer(read_parameter(parameter, 1))} end |
.retrieve_parameters(first, second, parameter, type) ⇒ Hash (private)
method to retrive the parameters for the given type
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/output/parameter_collector.rb', line 62 private_class_method def self.retrieve_parameters(first, second, parameter, type) begin case type when 'Integer' return retrieve_integer_parameters(first, second, parameter) when 'Float' return retrieve_float_parameters(first, second, parameter) else TerminalVis::print_error(" Error: unknown parameter: #{type}") end rescue ArgumentError (parameter, type) end end |