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(css_styles) ⇒ TableHelper

Returns a new instance of TableHelper.



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

def initialize(css_styles)
  @css_styles = css_styles
  @bm = BootstrapMarkup.new
end

Instance Method Details

#headers(*labels) ⇒ Object



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

def headers(*labels)
  @bm.table_begin(@css_styles)
  @bm.headers_begin
  labels.each do |h|
    @bm.header_begin
    @bm.header_content(h)
    @bm.header_end
  end
  @bm.headers_end
end

#renderObject



29
30
31
32
# File 'lib/coursegen/course/helpers/table_helpers.rb', line 29

def render
  @bm.table_end
  @bm.render
end

#row(*cells) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/coursegen/course/helpers/table_helpers.rb', line 19

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