class TableFu::Formatting
Public Class Methods
bar(percent)
click to toggle source
In order to show a sideways bar chart, we're extending the builtin TableFu
formatters.
# File lib/table_setter/table.rb, line 221 def bar(percent) percent = percent.to_f if percent < 1 percent = percent * 100 end "<div class=\"bar\" style=\"width:#{percent}%\">#{percent}%</div>" end
join(*args)
click to toggle source
join multiple columns, with optional delimiter
# File lib/table_setter/table.rb, line 254 def join(*args) args.join(" ") end
joinbr(*args)
click to toggle source
# File lib/table_setter/table.rb, line 258 def joinbr(*args) args.join("<br>") end
joincomma(*args)
click to toggle source
# File lib/table_setter/table.rb, line 262 def joincomma(*args) args.join(", ") end
link(linkname, href)
click to toggle source
format as a link, if the href is empty don't make the link active
# File lib/table_setter/table.rb, line 234 def link(linkname, href) title = linkname.to_s.gsub(/(["])/, "'") if !href.value.nil? && !href.value.to_s().empty? "<a href=\"#{href}\" title=\"#{title}\">#{linkname}</a>" else "<a title=\"#{title}\">#{linkname}</a>" end end
markdown(cell)
click to toggle source
markdown formatting in tablefu cells
# File lib/table_setter/table.rb, line 229 def markdown(cell) RDiscount.new(cell).to_html end
small(cell)
click to toggle source
make it small
# File lib/table_setter/table.rb, line 249 def small(cell) "<small>#{cell}</small>" end
strong(cell)
click to toggle source
make it strong
# File lib/table_setter/table.rb, line 244 def strong(cell) "<strong>#{cell}</strong>" end