Class: IrsForms::Form1099

Inherits:
Form
  • Object
show all
Defined in:
lib/irs_forms/form1099.rb

Overview

Base class for Form1099s

Direct Known Subclasses

Form1099Int, Form1099Misc

Constant Summary collapse

COPIES =
%W{A B C 1 2}

Instance Attribute Summary collapse

Attributes inherited from Form

#data, #x_offset, #y_offset

Instance Method Summary collapse

Methods inherited from Form

#template_filepath, #to_pdf

Constructor Details

#initialize(options = {}) ⇒ Form1099

Returns a new instance of Form1099.



8
9
10
11
12
13
14
# File 'lib/irs_forms/form1099.rb', line 8

def initialize(options={})
  options[:data] ||= []
  super

  self.copy = options[:copy]
  check_valid_copy! if copy.present?
end

Instance Attribute Details

#copyObject

Returns the value of attribute copy.



4
5
6
# File 'lib/irs_forms/form1099.rb', line 4

def copy
  @copy
end

Instance Method Details

#to_prawn(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/irs_forms/form1099.rb', line 16

def to_prawn(options={})
  options.reverse_merge!(with_template: false)

  prawn_options = {:bottom_margin => 0.0}
  prawn_options.merge!(:template => template_filepath) if options[:with_template]

  @pdf = Prawn::Document.new(prawn_options)

  data.each_with_index do |hash, index|
    position = calculate_position(index)
    @pdf.start_new_page(prawn_options) if index > 0 and position == :top
    render_data_to_prawn(hash, position)
  end

  @pdf
end