class Btgen::BootstrapTable
Attributes
headers[RW]
rows[RW]
Public Class Methods
new(args)
click to toggle source
# File lib/btgen/bootstrap_table.rb, line 7 def initialize(args) @args = args args[:class] = "table table-striped #{args[:class]}".split(' ').sort.uniq @headers = [] @rows = [] end
Public Instance Methods
to_html()
click to toggle source
# File lib/btgen/bootstrap_table.rb, line 15 def to_html content_tag :table, @args do build_headers + build_body end end
Private Instance Methods
build_body()
click to toggle source
# File lib/btgen/bootstrap_table.rb, line 29 def build_body content_tag :tbody do @rows.map do |row| content_tag :tr do Array(row).map do |cell| content_tag :td, cell end.inject(:+) end end.inject(:+) end end
build_headers()
click to toggle source
# File lib/btgen/bootstrap_table.rb, line 23 def build_headers content_tag :thead do @headers.map { |cell| content_tag :th, cell }.inject(:+) end end