Sha256: e3ea5376eebf36db25bc3c7b2f25281a25dd7e9365c22a427846ed4943091bb1

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

# coding: utf-8

module Thinreports
  module Generator::PDF::Drawer

    class List < Base
      # @param (see PDF::Drawer::Base#initialize)
      def initialize(pdf, format)
        super
        @sections = {}
      end

      # @param [Thinreports::Core::Shape::List::PageState] list_page
      def draw(list_page)
        draw_section(list_page.header) if list_page.header
        list_page.rows.each do |row|
          draw_section(row)
        end

        # Returns Thinreports::Report::Page object
        manager = list_page.parent.manager

        list_id = list_page.id.to_s
        manager.format.shapes.each do |id, shape|
          next unless list_pageno?(list_id, shape)

          shape = manager.final_shape(id)
          @pdf.draw_shape_pageno(shape.internal,
                                 list_page.no, list_page.manager.page_count)
        end
      end

    private

      # @param [String] list_id
      # @param [Thinreports::Core::Shape::Base::Format] shape
      # @return [Boolean]
      def list_pageno?(list_id, shape)
        shape.type == Thinreports::Core::Shape::PageNumber::TYPE_NAME &&
        shape.target == list_id
      end

      # @param [Thinreports::Core::Shape::List::SectionInterface] section
      def draw_section(section)
        internal = section.internal
        drawer(internal).draw(section, internal.relative_position)
      end

      # @param [Thinreports::Core::Shape::List::SectionInternal] section
      # @return [Thinreports::Generator::PDF::Drawer::ListSection]
      def drawer(section)
        @sections[section.section_name] ||= ListSection.new(@pdf, section)
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.8.2 lib/thinreports/generator/pdf/drawer/list.rb
thinreports-0.8.1 lib/thinreports/generator/pdf/drawer/list.rb
thinreports-0.8.0 lib/thinreports/generator/pdf/drawer/list.rb