Class: Dieses::Application::Sheets::Table

Inherits:
Dieses::Application::Sheet show all
Defined in:
lib/dieses/application/sheets/table.rb

Constant Summary collapse

TABLES =
{
  '1': Param.(row: 2,  col: 2),
  '2': Param.(row: 5,  col: 2),
  '3': Param.(row: 4,  col: 4),
  '4': Param.(row: 10, col: 4)
}.freeze

Instance Attribute Summary

Attributes inherited from Dieses::Application::Sheet

#paper, #variant

Instance Method Summary collapse

Methods inherited from Dieses::Application::Sheet

default_variant, #initialize, #produce, variant!

Methods included from Dieses::Application::Sheet::DSL

extended, #sheet, #variant, #variate

Constructor Details

This class inherits a constructor from Dieses::Application::Sheet

Instance Method Details

#callObject

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dieses/application/sheets/table.rb', line 25

def call # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
  row, col = TABLES[param.table].to_a

  cell_width,  total_width  = Ruler.divide(unit: param.unit, multiple: col, length: canvas.width)
  cell_height, total_height = Ruler.divide(unit: param.unit, multiple: row, length: canvas.height)

  draw unit: param.unit do
    repeat row + 1 do
      hline :hline, length: total_width
      down cell_height
    end
    repeat row do
      down cell_height / 2
      hline :half, :dashed, :fine, length: total_width
      down cell_height / 2
    end
    repeat col + 1 do
      vline :vline, length: total_height
      right cell_width
    end
  end
end