Class: TableFu::Formatting

Inherits:
Object
  • Object
show all
Defined in:
lib/table_setter/table.rb

Class Method Summary

Class Method Details

+ (Object) bar(percent)

In order to show a sideways bar chart, we’re extending the builtin TableFu formatters.



218
219
220
221
222
223
224
# File 'lib/table_setter/table.rb', line 218

def bar(percent)
  percent = percent.to_f
  if percent < 1
    percent = percent * 100
  end
  "<div class=\"bar\" style=\"width:#{percent}%\">#{percent}%</div>"
end