Class: BootstrapBuilders::Panel

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

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Panel

Returns a new instance of Panel.



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

def initialize(args)
  @title = args.fetch(:title)
  @controls = args[:controls]
  @table = args[:table]
  @block = args.fetch(:block)
  @context = args.fetch(:context)
  @class = args[:class]
  @data = args[:data]

  @css = {}
  @css[:width] = args.fetch(:width) if args[:width]
end

Instance Method Details

#html ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bootstrap_builders/panel.rb', line 15

def html
  @panel = HtmlGen::Element.new(:div, inden: "  ", classes: container_classes, css: @css, data: @data)

  add_heading if @title || @controls

  if @table
    add_table
  else
    add_body
  end

  html = @panel.html

  if html.respond_to?(:html_safe)
    html.html_safe
  else
    html
  end
end