Sha256: a8611cc809726164aa980f4e98e67a7a8c757e266c6f07156f46c24de4a68736
Contents?: true
Size: 1.74 KB
Versions: 7
Compression:
Stored size: 1.74 KB
Contents
# frozen_string_literal: true require_relative 'section_renderer' module Thinreports module SectionReport module Renderer class GroupRenderer def initialize(pdf) @pdf = pdf @section_renderer = Renderer::SectionRenderer.new(pdf) end def render(report, group) pdf.start_new_page_for_section_report report.schema current_page_height = 0 max_page_height = pdf.max_content_height group.headers.each do |header| section_renderer.render(header) current_page_height += section_renderer.section_height(header) end group.details.each do |detail| if current_page_height + section_renderer.section_height(detail) > max_page_height pdf.start_new_page_for_section_report report.schema current_page_height = 0 group.headers.each do |header| if header.schema.every_page? section_renderer.render(header) current_page_height += section_renderer.section_height(header) end end end section_renderer.render(detail) current_page_height += section_renderer.section_height(detail) end group.footers.each do |footer| if current_page_height + section_renderer.section_height(footer) > max_page_height pdf.start_new_page_for_section_report report.schema current_page_height = 0 end section_renderer.render(footer) current_page_height += section_renderer.section_height(footer) end end private attr_reader :pdf, :section_renderer end end end end
Version data entries
7 entries across 7 versions & 1 rubygems