class Thinreports::Generator::PDF::Drawer::List

Public Class Methods

new(pdf, format) click to toggle source

@param (see PDF::Drawer::Base#initialize)

# File lib/thinreports/generator/pdf/drawer/list.rb, line 9
def initialize(pdf, format)
  super
  @sections = {}
end

Public Instance Methods

draw(list_page) click to toggle source

@param [Thinreports::Core::Shape::List::PageState] list_page

# File lib/thinreports/generator/pdf/drawer/list.rb, line 15
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 Instance Methods

draw_section(section) click to toggle source

@param [Thinreports::Core::Shape::List::SectionInterface] section

# File lib/thinreports/generator/pdf/drawer/list.rb, line 45
def draw_section(section)
  internal = section.internal

  base_top = @format.section_base_position_top(internal.section_name)
  position = [internal.relative_left, base_top + internal.relative_top]

  drawer(internal).draw(section, position)
end
drawer(section) click to toggle source

@param [Thinreports::Core::Shape::List::SectionInternal] section @return [Thinreports::Generator::PDF::Drawer::ListSection]

# File lib/thinreports/generator/pdf/drawer/list.rb, line 56
def drawer(section)
  @sections[section.section_name] ||= ListSection.new(@pdf, section)
end
list_pageno?(list_id, shape) click to toggle source

@param [String] list_id @param [Thinreports::Core::Shape::Base::Format] shape @return [Boolean]

# File lib/thinreports/generator/pdf/drawer/list.rb, line 39
def list_pageno?(list_id, shape)
  shape.type == Thinreports::Core::Shape::PageNumber::TYPE_NAME &&
    shape.target == list_id
end