Class: CardPrinter::SixByFourRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/card_printer/six_by_four_renderer.rb

Constant Summary collapse

TITLE_SIZE =
12.mm
DESCRIPTION_SIZE =
7.mm

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stories, opts = {}) ⇒ SixByFourRenderer

Returns a new instance of SixByFourRenderer.



14
15
16
17
18
19
# File 'lib/card_printer/six_by_four_renderer.rb', line 14

def initialize(stories, opts = {})
  @stories = stories
  @scale = 1
  @opts = opts
  @iteration_number = opts[:iteration_number]
end

Class Method Details

.descriptionObject



10
11
12
# File 'lib/card_printer/six_by_four_renderer.rb', line 10

def self.description
  "6x4 record cards (use manual feed)"
end

Instance Method Details

#render_to(destination) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/card_printer/six_by_four_renderer.rb', line 21

def render_to(destination)
  @pdf = Prawn::Document.new(:page_layout => :landscape,
                           :margin      => 0,
                           :page_size   => [102.mm, 152.mm])


  @stories.each.with_index do |story, i|
    @pdf.start_new_page unless i == 0
    render_story(story)
  end

  @pdf.render_file destination
rescue Exception
  puts "[!] There was an error while generating the PDF file... What happened was:"
  raise
end