Class: SimpleInvoice::Emailer::EmailInvoiceTextTable
- Inherits:
-
Object
- Object
- SimpleInvoice::Emailer::EmailInvoiceTextTable
- Defined in:
- lib/simple_invoice/emailer/email_invoice_text_table.rb
Instance Method Summary collapse
-
#initialize ⇒ EmailInvoiceTextTable
constructor
A new instance of EmailInvoiceTextTable.
- #line_item(values) ⇒ Object
- #text_table ⇒ String
- #to_s ⇒ Object
- #total(total) ⇒ Object
Constructor Details
#initialize ⇒ EmailInvoiceTextTable
Returns a new instance of EmailInvoiceTextTable.
7 8 9 10 11 |
# File 'lib/simple_invoice/emailer/email_invoice_text_table.rb', line 7 def initialize @table = Text::Table.new @table.rows = [] @invoice_rows = [] end |
Instance Method Details
#line_item(values) ⇒ Object
13 14 15 |
# File 'lib/simple_invoice/emailer/email_invoice_text_table.rb', line 13 def line_item values @invoice_rows << values.values_at(*[:description, :price, :quantity, :total]).collect(&:to_s) end |
#text_table ⇒ String
22 23 24 25 26 27 28 29 30 |
# File 'lib/simple_invoice/emailer/email_invoice_text_table.rb', line 22 def text_table @table.head = left ['Description', 'Price', 'Quantity', 'Total'] set_column_alignments [:left, :right, :right, :right] @invoice_rows.each do |row| add_row row end @table.foot = [{:value => 'Total', :colspan => 3}, right(@total)] @table end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/simple_invoice/emailer/email_invoice_text_table.rb', line 32 def to_s text_table.to_s end |
#total(total) ⇒ Object
17 18 19 |
# File 'lib/simple_invoice/emailer/email_invoice_text_table.rb', line 17 def total total @total = total end |