Class: Repor::Serializers::TableSerializer

Inherits:
BaseSerializer show all
Defined in:
lib/repor/serializers/table_serializer.rb

Direct Known Subclasses

CsvSerializer, HighchartsSerializer

Instance Attribute Summary

Attributes inherited from BaseSerializer

#report

Instance Method Summary collapse

Methods inherited from BaseSerializer

#axis_summary, #filter_summary, #human_aggregator_label, #human_aggregator_value_label, #human_category_value_label, #human_dimension_label, #human_dimension_value_label, #human_null_value_label, #human_number_value_label, #human_time_value_label, #initialize, #record_type, #time_formats

Constructor Details

This class inherits a constructor from Repor::Serializers::BaseSerializer

Instance Method Details

#captionObject



16
17
18
# File 'lib/repor/serializers/table_serializer.rb', line 16

def caption
  axis_summary
end

#each_rowObject



8
9
10
11
12
13
14
# File 'lib/repor/serializers/table_serializer.rb', line 8

def each_row
  return to_enum(__method__) unless block_given?

  report.flat_data.each do |xes, y|
    yield report.groupers.zip(xes).map { |d, v| human_dimension_value_label(d, v) } + [human_aggregator_value_label(report.aggregator, y)]
  end
end

#headersObject



4
5
6
# File 'lib/repor/serializers/table_serializer.rb', line 4

def headers
  report.groupers.map(&method(:human_dimension_label)) + [human_aggregator_label(report.aggregator)]
end