Class: CheckWriter::Check

Inherits:
Object
  • Object
show all
Includes:
AttributeFormatting
Defined in:
lib/check_writer/check.rb

Overview

Check generates checks as a PDF

Constant Summary collapse

STUB_FORMATS =
[:one_third, :two_thirds]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AttributeFormatting

#amount_in_words, #cents, #dollars, #formatted_amount, #formatted_date

Constructor Details

#initialize(attributes = {}) ⇒ Check

Returns a new instance of Check.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/check_writer/check.rb', line 22

def initialize(attributes={})
  attributes.reverse_merge!(
    :date => Date.today,
    :void => false,
    :blank => false,
    :with_stubs => false,
    :stub_table_data => [],
    :stub_table_options => {},
    :stub_table_lambda => nil,
    :stub_format => :one_third
  )

  _assign_attributes(attributes)
end

Instance Attribute Details

#account_numberObject

Returns the value of attribute account_number.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def 
  @account_number
end

#amountObject

Returns the value of attribute amount.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def amount
  @amount
end

#bank_addressObject

Returns the value of attribute bank_address.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def bank_address
  @bank_address
end

#bank_fractionObject

Returns the value of attribute bank_fraction.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def bank_fraction
  @bank_fraction
end

#bank_nameObject

Returns the value of attribute bank_name.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def bank_name
  @bank_name
end

#blankObject

Returns the value of attribute blank.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def blank
  @blank
end

#dateObject

Returns the value of attribute date.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def date
  @date
end

#memoObject

Returns the value of attribute memo.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def memo
  @memo
end

#numberObject

Returns the value of attribute number.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def number
  @number
end

#payee_addressObject

Returns the value of attribute payee_address.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def payee_address
  @payee_address
end

#payee_nameObject

Returns the value of attribute payee_name.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def payee_name
  @payee_name
end

#payor_addressObject

Returns the value of attribute payor_address.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def payor_address
  @payor_address
end

#payor_nameObject

Returns the value of attribute payor_name.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def payor_name
  @payor_name
end

#routing_numberObject

Returns the value of attribute routing_number.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def routing_number
  @routing_number
end

#second_signature_lineObject

Returns the value of attribute second_signature_line.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def second_signature_line
  @second_signature_line
end

#signature_image_fileObject

Returns the value of attribute signature_image_file.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def signature_image_file
  @signature_image_file
end

#stub_formatObject

Returns the value of attribute stub_format.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def stub_format
  @stub_format
end

#stub_table_dataObject

Returns the value of attribute stub_table_data.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def stub_table_data
  @stub_table_data
end

#stub_table_lambdaObject

Returns the value of attribute stub_table_lambda.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def stub_table_lambda
  @stub_table_lambda
end

#stub_table_optionsObject

Returns the value of attribute stub_table_options.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def stub_table_options
  @stub_table_options
end

#voidObject

Returns the value of attribute void.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def void
  @void
end

#with_stubsObject

Returns the value of attribute with_stubs.



10
11
12
# File 'lib/check_writer/check.rb', line 10

def with_stubs
  @with_stubs
end

Instance Method Details

#to_pdfObject

Renders the check as a pdf and returns the pdf data



38
39
40
# File 'lib/check_writer/check.rb', line 38

def to_pdf
  to_prawn.render
end

#to_prawn(pdf = nil) ⇒ Object

Renders the check and returns the Prawn::Document for further manipulation.

To use an existing Prawn::Document, pass this in as the pdf argument. If pdf is nil, a new Prawn::Document will be created.



48
49
50
51
52
# File 'lib/check_writer/check.rb', line 48

def to_prawn(pdf=nil)
  @pdf = pdf||Prawn::Document.new(:bottom_margin => 0.0)
  _generate_check_pdf
  @pdf
end