each do |week|
tr do
th :style=>"vertical-align:top;" do
p "Week \##{week[:week_number]}, #{week[:year]}"
end
td do
div :class=>:weekday_bar,
:style=>"width:" << ((week[:weekday_amount] /
max_gross * 199 ) + 1).to_s do
" "
end
span "Week - $#{'%0.2f' % week[:weekday_amount]}"
end
end
tr do
td ""
td do
div :class=>:weekend_bar,
:style=>"width: " << ((week[:weekend_amount] /
max_gross * 199) + 1 ).to_s do
' '
end
span "Weekend - $#{'%0.2f' % week[:weekend_amount]}"
end
end
end
end
end
end
end
puts mab
CHAPTER 7 n TRACKING EXPENDITURES WITH PAYPAL 147
Save the code as paypal_expense_report.rb. You can run the code as follows:
ruby paypal_paypal_expense_report.rb mysql_hostname mysql_username mysql_password
paypal > report.html
As before, replace the italicized arguments with the appropriate values for your
system.
At this point, report.html should contain a neatly formatted report, showing a graph
of weekend vs. weekday spending for each day in the report. If you open it in a web
browser, you should see a result similar to Figure 7-3.
Pages:
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216