Sha256: ec9ff169e089581ec697b5324cdbfab992889348966444e4b5d81feadd09a7ea
Contents?: true
Size: 880 Bytes
Versions: 1
Compression:
Stored size: 880 Bytes
Contents
require 'prawn' require "prawn/measurement_extensions" module DotGrid class Generator attr_accessor( :pdf, :file_name, :page_size, :margin, :pages, :page_types ) def initialize(params) @file_name = params[:file_name] || "dotgrid.pdf" @page_size = params[:page_size] || "LETTER" @margin = params[:margin] || 0.5 @page_types = params[:page_types] ? params[:page_types].split(",") : ["planner"] @pdf = Prawn::Document.new(margin: margin, page_size: page_size, skip_page_creation: true) params[:pdf] = pdf @pages = create_pages(params) end def create_pages(params) page_types.map do |p| DotGrid::Page::Factory.build(p.strip, params.clone) end end def generate pages.each { |page| page.generate } pdf.render_file file_name end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dot_grid-0.0.6 | lib/dot_grid/generator.rb |