Class: Krupuk::Layout

Inherits:
Object
  • Object
show all
Defined in:
lib/krupuk/layout.rb

Instance Method Summary collapse

Constructor Details

#initialize(pack) ⇒ Layout

Returns a new instance of Layout.



5
6
7
8
9
# File 'lib/krupuk/layout.rb', line 5

def initialize(pack)
  @pack   = pack
  @config = Krupuk.configuration
  @pdf    = create_pdf
end

Instance Method Details

#renderObject



11
12
13
14
15
16
17
18
# File 'lib/krupuk/layout.rb', line 11

def render
  @pack.cards
    .each_slice(@config.cards_per_sheet)
    .each_with_index do |sheet_cards, i|
      Sheet.new(sheet_cards, pdf: @pdf, config: @config, first_sheet: i.zero?).render
    end
  @pdf
end