Prev | Current Page 210 | Next

David Berube

"Practical Reporting with Ruby and Rails"

weekday_bar { display:block; background-color: blue; }
.weekend_bar { display:block; background-color: red; }
%]
end
end
Essentially, the code creates a Markaby::Builder object. You pass it a block. Inside that
block, you can use methods named after HTML tags??”html, head, tr, td, p, and so on??”and
these methods will produce corresponding HTML code.
The first part of the code here sets up your document, adding a head and a title. It
also adds a style element, which sets up your two CSS classes: weekday_bar and
weekend_bar, used for the weekday and weekend bar portions of the graph, respectively.
Next, let??™s take a look at the heart of the Markaby code:
body do
table do
weeks.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,
CHAPTER 7 n TRACKING EXPENDITURES WITH PAYPAL 152
:style=>"width: " <<
((week[:weekend_amount] /
max_gross * 199) + 1 ).


Pages:
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
yerba mate tanie perfumy pieniny noclegi Koraliki mafia poradnik