Class: TableHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/coursegen/course/helpers/table_helpers.rb

Overview

Class TableHelper provides methods for creating a table.

Instance Method Summary collapse

Constructor Details

#initialize(*property) ⇒ TableHelper

Returns a new instance of TableHelper.



3
4
5
6
# File 'lib/coursegen/course/helpers/table_helpers.rb', line 3

def initialize(*property)
  @prop = property
  @bm = BootstrapMarkup.new
end

Instance Method Details

#headers(*labels) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/coursegen/course/helpers/table_helpers.rb', line 8

def headers(*labels)
  css_style = ''
  css_style += ' table-condensed' if @prop.include? :normal
  css_style += ' table-bordered' if @prop.include? :bordered
  @bm.table_begin(css_style)
  @bm.headers_begin
  labels.each do |h|
    @bm.header_begin
    @bm.header_content(h)
    @bm.header_end
  end
  @bm.headers_end
end

#renderObject



32
33
34
35
# File 'lib/coursegen/course/helpers/table_helpers.rb', line 32

def render
  @bm.table_end
  @bm.render
end

#row(*cells) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/coursegen/course/helpers/table_helpers.rb', line 22

def row(*cells)
  @bm.row_begin
  cells.each do |c|
    @bm.cell_begin
    @bm.cell_content(c)
    @bm.cell_end
  end
  @bm.row_end
end