Class: DataOutput::DeltaOutput

Inherits:
DatasetOutput show all
Defined in:
lib/output/data_output/delta_output.rb

Overview

Data output for the difference of two data sets for the terminal visualization

Instance Attribute Summary

Attributes inherited from DatasetOutput

#meta_data

Attributes inherited from BaseOutput

#data_set, #legend, #with_extreme_values

Instance Method Summary collapse

Methods inherited from DatasetOutput

#print_meta_information, #print_meta_tail

Methods inherited from BaseOutput

#determine_output_type_and_print_value, #print_data, #print_data_and_get_extrema, #print_domain_information, #print_extreme_information, #print_extreme_values_for, #print_meta_information, #set_attributes

Constructor Details

#initialize(data_set, meta_data, indices, options) ⇒ DeltaOutput

method to visualize the difference of two datasets

Parameters:

  • data_set (DataSet)

    the dataset which should be visualized

  • meta_data (VisMetaData)

    the corresponding meta data

  • indices (Hash)

    the indices of the two datasets which should be substracted

  • options (Hash)

    hash with the boolean values for extreme values and extended legend output



19
20
21
22
23
24
25
26
27
28
# File 'lib/output/data_output/delta_output.rb', line 19

def initialize(data_set, , indices, options)
  @meta_data = 
  set_attributes(data_set, options[:extreme_values])
  @legend = ColorLegend::ColorDelta.
                         new(data_set.min_value, data_set.max_value)

  print_output_head(indices)
  print_data(options[:legend], @meta_data.domain_x, @meta_data.domain_y)
  nil
end

Instance Method Details

method to print additional information before the x and y domain informations



46
47
48
49
# File 'lib/output/data_output/delta_output.rb', line 46

def print_meta_head
  puts "\nDataset: Difference of #{@meta_data.name} between two datasets"
  nil
end

creates a headline before printing the data set with the requested indices

Parameters:

  • indices (Hash)

    the indices of the two datasets which should be substracted



36
37
38
39
40
41
42
# File 'lib/output/data_output/delta_output.rb', line 36

def print_output_head(indices)
  first_year = @meta_data.domain_z.lower + indices[:first]
  second_year = @meta_data.domain_z.lower + indices[:second]
  puts "Printing difference for the datasets of #{first_year} and "\
       "#{second_year}.\n\n"
  nil
end