Module: TerminalVis
- Defined in:
- lib/output/output.rb,
lib/main/main_module.rb,
lib/math/interpolation.rb,
lib/math/linear_interpolation.rb,
lib/math/region_interpolation.rb,
lib/output/parameter_collector.rb,
lib/math/bilinear_interpolation.rb
Overview
This module holds the main singleton methods that are called from the script. It also stores the data ans parameter repository so it can be called from the other classes and modules if they need data oder parameter informations.
Defined Under Namespace
Modules: Interpolation, Output, ParameterCollector
Class Attribute Summary collapse
-
.data_repo ⇒ DataRepository
readonly
The repository storing the datasets.
-
.option_handler ⇒ Configuration_Handler
readonly
The handler controlling the configuration parameter.
-
.parameter_handler ⇒ Parameter::ParameterHandler
readonly
The handler controlling the parameters.
Class Method Summary collapse
-
.check_index(meta_data, index) ⇒ Object
private
method to check if provided integer index lies in range of dataseries.
-
.create_metadata ⇒ VisMetaData
creates the MetaData::VisMetaData based on the provided parameters.
-
.determine_configuration_options ⇒ Object
method to adjust the default options if the parameter was provided.
-
.get_and_check_index(meta_data) ⇒ Integer
checks if option -i was used, determines if a valid parameter was entered and returns the index on success.
-
.initialize_repositories(arguments) ⇒ Object
singleton method to initialize the required repositories.
-
.print_error(message) ⇒ Object
call for standard error output.
-
.print_help ⇒ Object
call to print the help text.
-
.print_version ⇒ Object
call to print version number and author.
Class Attribute Details
.data_repo ⇒ DataRepository (readonly)
Returns the repository storing the datasets.
19 20 21 |
# File 'lib/main/main_module.rb', line 19 def data_repo @data_repo end |
.option_handler ⇒ Configuration_Handler (readonly)
Returns the handler controlling the configuration parameter.
25 26 27 |
# File 'lib/main/main_module.rb', line 25 def option_handler @option_handler end |
.parameter_handler ⇒ Parameter::ParameterHandler (readonly)
Returns the handler controlling the parameters.
22 23 24 |
# File 'lib/main/main_module.rb', line 22 def parameter_handler @parameter_handler end |
Class Method Details
.check_index(meta_data, index) ⇒ Object (private)
method to check if provided integer index lies in range of dataseries
103 104 105 106 107 108 109 110 111 |
# File 'lib/main/main_module.rb', line 103 private_class_method def self.check_index(, index) if (index < 0 || index >= @data_repo.repository[].series.size) text_index = @parameter_handler.repository.parameters[:index] data_size = @data_repo.repository[].series.size = " Error: input #{text_index} for -i is not valid" \ " for dataset with length #{data_size}".red print_error() end end |
.create_metadata ⇒ VisMetaData
creates the MetaData::VisMetaData based on the provided parameters
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/main/main_module.rb', line 38 def self. begin if (@parameter_handler.repository.parameters[:meta]) @data_repo.add_data(@parameter_handler.repository.parameters[:file]) else @data_repo.( @parameter_handler.repository.parameters[:file]) end rescue StandardError => e print_error(" Error while creating metadata:\n ".concat(e.)) end end |
.determine_configuration_options ⇒ Object
method to adjust the default options if the parameter was provided
52 53 54 55 56 57 |
# File 'lib/main/main_module.rb', line 52 def self. if (@parameter_handler.repository.parameters[:option]) @option_handler.process_parameter(@parameter_handler. repository.parameters[:option]) end end |
.get_and_check_index(meta_data) ⇒ Integer
checks if option -i was used, determines if a valid parameter was entered and returns the index on success
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/main/main_module.rb', line 82 def self.get_and_check_index() index = 0 # default data set if -i not set or only one data set if (@parameter_handler.repository.parameters[:index]) begin # make sure that parameter of -i is an integer index = Integer(@parameter_handler.repository.parameters[:index]) - 1 rescue ArgumentError = " Error: argument of -i is not a number: " \ "#{@parameter_handler.repository.parameters[:index]}".red print_error() end check_index(, index) end return index end |
.initialize_repositories(arguments) ⇒ Object
singleton method to initialize the required repositories
30 31 32 33 34 |
# File 'lib/main/main_module.rb', line 30 def self.initialize_repositories(arguments) @parameter_handler = Parameter::ParameterHandler.new(arguments) @data_repo = DataInput::DataRepository.new() @option_handler = ConfigurationHandler.new() end |
.print_error(message) ⇒ Object
call for standard error output
72 73 74 75 |
# File 'lib/main/main_module.rb', line 72 def self.print_error() puts "#{}".red puts 'For help type: ruby <script> --help'.green end |
.print_help ⇒ Object
call to print the help text
60 61 62 |
# File 'lib/main/main_module.rb', line 60 def self.print_help HelpOutput.print_help_for(@parameter_handler.repository.parameters[:help]) end |
.print_version ⇒ Object
call to print version number and author
65 66 67 68 |
# File 'lib/main/main_module.rb', line 65 def self.print_version puts 'terminal_visualization version 0.9.2'.yellow puts 'Created by Benjamin Held (June 2015)'.yellow end |