Class: BootstrapBuilders::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/bootstrap_builders/table.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Table

Returns a new instance of Table.



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/bootstrap_builders/table.rb', line 2

def initialize(args)
  @args = args

  if args.key?(:blk)
    @blk = args.fetch(:blk)
  else
    @content = args.fetch(:content)
  end

  @context = args.fetch(:context)
end

Instance Method Details

#html ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bootstrap_builders/table.rb', line 14

def html
  if @blk
    buffer = @context.(:table, attributes, &@blk)
  else
    buffer = @context.(:table, @content, attributes)
  end

  return buffer unless @args[:responsive]

  @context.(:div, buffer, class: "table-responsive")
end