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.
222 223 224 225 226 227 228 |
# File 'lib/table_setter/table.rb', line 222 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
255 256 257 |
# File 'lib/table_setter/table.rb', line 255 def join(*args) args.join(" ") end |
.joinbr(*args) ⇒ Object
259 260 261 |
# File 'lib/table_setter/table.rb', line 259 def joinbr(*args) args.join("<br>") end |
.joincomma(*args) ⇒ Object
263 264 265 |
# File 'lib/table_setter/table.rb', line 263 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
235 236 237 238 239 240 241 242 |
# File 'lib/table_setter/table.rb', line 235 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
230 231 232 |
# File 'lib/table_setter/table.rb', line 230 def markdown(cell) RDiscount.new(cell).to_html end |
.small(cell) ⇒ Object
make it small
250 251 252 |
# File 'lib/table_setter/table.rb', line 250 def small(cell) "<small>#{cell}</small>" end |
.strong(cell) ⇒ Object
make it strong
245 246 247 |
# File 'lib/table_setter/table.rb', line 245 def strong(cell) "<strong>#{cell}</strong>" end |