Class: TableFu::Formatting
- Inherits:
-
Object
- Object
- TableFu::Formatting
- Defined in:
- lib/table_setter/table.rb
Class Method Summary collapse
-
.bar(percent) ⇒ Object
In order to show a sideways bar chart, we’re extending the builtin TableFu formatters.
-
.join(*args) ⇒ Object
join multiple columns, with optional delimiter.
- .joinbr(*args) ⇒ Object
- .joincomma(*args) ⇒ Object
-
.link(linkname, href) ⇒ Object
format as a link, if the href is empty don’t make the link active.
-
.markdown(cell) ⇒ Object
markdown formatting in tablefu cells.
-
.small(cell) ⇒ Object
make it small.
-
.strong(cell) ⇒ Object
make it strong.
Class Method Details
.bar(percent) ⇒ Object
In order to show a sideways bar chart, we’re extending the builtin TableFu formatters.
221 222 223 224 225 226 227 |
# File 'lib/table_setter/table.rb', line 221 def (percent) percent = percent.to_f if percent < 1 percent = percent * 100 end "<div class=\"bar\" style=\"width:#{percent}%\">#{percent}%</div>" end |
.join(*args) ⇒ Object
join multiple columns, with optional delimiter
254 255 256 |
# File 'lib/table_setter/table.rb', line 254 def join(*args) args.join(" ") end |
.joinbr(*args) ⇒ Object
258 259 260 |
# File 'lib/table_setter/table.rb', line 258 def joinbr(*args) args.join("<br>") end |
.joincomma(*args) ⇒ Object
262 263 264 |
# File 'lib/table_setter/table.rb', line 262 def joincomma(*args) args.join(", ") end |
.link(linkname, href) ⇒ Object
format as a link, if the href is empty don’t make the link active
234 235 236 237 238 239 240 241 |
# 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) ⇒ Object
markdown formatting in tablefu cells
229 230 231 |
# File 'lib/table_setter/table.rb', line 229 def markdown(cell) RDiscount.new(cell).to_html end |
.small(cell) ⇒ Object
make it small
249 250 251 |
# File 'lib/table_setter/table.rb', line 249 def small(cell) "<small>#{cell}</small>" end |
.strong(cell) ⇒ Object
make it strong
244 245 246 |
# File 'lib/table_setter/table.rb', line 244 def strong(cell) "<strong>#{cell}</strong>" end |