Class: RangeOutput
- Inherits:
-
Object
- Object
- RangeOutput
- Defined in:
- lib/output/range_output.rb
Overview
Output class for printing datasets of a data series within a given range
Instance Method Summary collapse
-
#check_range_parameters(meta_data, indices) ⇒ boolean
private
method to check if the input parameters are valid.
-
#determine_animation(parameters) ⇒ Object
private
method to determine the art of visualization.
-
#determine_output_resolution(data_series, meta_data, options) ⇒ Object
private
method to determine which type of output should be used.
-
#first_lesser_second?(indices) ⇒ boolean
private
method to check if the first parameter is lesser than the second.
-
#initialize(meta_data, data_series, parameters, options) ⇒ RangeOutput
constructor
singleton method to print the dataset within a given range.
-
#parameter_in_meta_range?(meta_data, indices) ⇒ boolean
private
method to check if the parameters are within the range specified by the MetaData::VisMetaData.
Constructor Details
#initialize(meta_data, data_series, parameters, options) ⇒ RangeOutput
singleton method to print the dataset within a given range
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/output/range_output.rb', line 18 def initialize(, data_series, parameters, ) check_range_parameters(, parameters) [:index] = parameters[:lower] while ([:index] <= parameters[:upper]) determine_output_resolution(data_series, , ) determine_animation(parameters) [:index] += 1 end end |
Instance Method Details
#check_range_parameters(meta_data, indices) ⇒ boolean (private)
method to check if the input parameters are valid
35 36 37 38 39 |
# File 'lib/output/range_output.rb', line 35 def check_range_parameters(, indices) first_lesser_second?(indices) (, indices) end |
#determine_animation(parameters) ⇒ Object (private)
method to determine the art of visualization. Without -all or animation speed = 0 the progress will be manual, speed > 0 determines speed in seconds
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/output/range_output.rb', line 90 def determine_animation(parameters) animation_speed = 0 if (parameters[:all]) animation_speed = Integer(parameters[:all]) end 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 |
#determine_output_resolution(data_series, meta_data, options) ⇒ Object (private)
method to determine which type of output should be used
79 80 81 82 83 84 85 |
# File 'lib/output/range_output.rb', line 79 def determine_output_resolution(data_series, , ) if (![:auto_scale]) DataOutput::SingleOutput.new(data_series, , ) else DataOutput::ScaledDatasetOutput.new(data_series, , ) end end |
#first_lesser_second?(indices) ⇒ boolean (private)
method to check if the first parameter is lesser than the second
45 46 47 48 49 50 51 |
# File 'lib/output/range_output.rb', line 45 def first_lesser_second?(indices) if (indices[:lower] >= indices[:upper]) raise ArgumentError, ' Error: First parameter of -r is equal or greater than the second'.red end return true end |
#parameter_in_meta_range?(meta_data, indices) ⇒ boolean (private)
method to check if the parameters are within the range specified by the MetaData::VisMetaData
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/output/range_output.rb', line 59 def (, indices) size = .domain_z.number_of_values if (indices[:lower] < 0) raise ArgumentError, ' Error: First parameter of -r is lesser or equal 0'.red end if (indices[:upper] >= size) raise ArgumentError, ' Error: Second parameter of -r greater than size of data series'.red end return true end |