class Taxedo::Builder::Html < Taxedo::Builder::Base
def generate(format, options={})
case format
when :lines then lines
when :rows then table_rows options[:columns], options[:custom_content]
else table
end
return @content.join("\n")
end
private
def lines
line t('subtotal'), subtotal, :class => 'subtotal'
taxes.each { |tax| line tax.name, tax.amount, :class => "tax #{tax.id}" }
line t('total'), total, :class => 'total'
end
def line(label, value, options={})
options = { :class => '' }.merge(options)
@content << ('
' + price(value) + '
')
end
def table
@content << ''
end
def table_rows(columns=0, custom_content='')
table_row t('subtotal'), subtotal, :class => 'subtotal', :custom_columns => columns, :custom_content => custom_content
taxes.each { |tax| table_row tax.name, tax.amount, :class => "tax #{tax.id}" }
table_row t('total'), total, :class => 'total'
end
def table_row(label, value, options={})
options = { :class => '', :custom_columns => 0, :custom_content => '' }.merge(options)
content = ['']
content << '' + options[:custom_content] + ' | ' if options[:custom_columns] > 0
content << '' + label + ' | ' + price(value) + ' |
'
@content << content.join
end
end