class HTMLInvoiceExporter
Public Class Methods
new(project)
click to toggle source
# File lib/kale/html_invoice_exporter.rb, line 3 def initialize project @project = project self.prefix self.body self.suffix self.write end
Protected Instance Methods
body()
click to toggle source
# File lib/kale/html_invoice_exporter.rb, line 28 def body self.body_builder end
body_builder()
click to toggle source
# File lib/kale/html_invoice_exporter.rb, line 44 def body_builder @html += %Q( <h1>#{@project.name}</h1> <table> <thead> <tr> <th>Work</th> <th>Time</th> </tr> </thead> <tbody> ) @project.sessions.each do |session| @html += %Q( <tr> <td>#{session.description}</td> <td>#{session.elapsed_time}</td> </tr> ) end @html += %Q( </tbody> <tfoot> <tr> <td> #{seconds_to_hms(@project.total_time)} </td> <td> #{@project.total_earned} </td> </tr> </tfoot> </table> ) end
prefix()
click to toggle source
# File lib/kale/html_invoice_exporter.rb, line 15 def prefix @html = %Q( <!doctype html> <html> <head> <title> #{@project.name} Invoice </title> </head> <body> ) end
suffix()
click to toggle source
# File lib/kale/html_invoice_exporter.rb, line 32 def suffix @html += "</body></html>" end
write()
click to toggle source
# File lib/kale/html_invoice_exporter.rb, line 36 def write filename = "#{@project.name}.html" file = File.open filename, 'w+' file.write @html file.close puts "Created an invoice - #{filename}" end