Class: BootstrapBuilders::Panel
- Inherits:
-
Object
- Object
- BootstrapBuilders::Panel
- Defined in:
- lib/bootstrap_builders/panel.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#controls ⇒ Object
Returns the value of attribute controls.
Class Method Summary collapse
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(args) ⇒ Panel
constructor
A new instance of Panel.
Constructor Details
#initialize(args) ⇒ Panel
Returns a new instance of Panel.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bootstrap_builders/panel.rb', line 20 def initialize(args) @title = args.fetch(:title) @table = args[:table] @context = args[:context] @class = args[:class] @data = args[:data] @controls = args[:controls] @controls = [@controls] unless @controls.is_a?(Array) @css = {} @css[:width] = args.fetch(:width) if args[:width] @block = proc do args.fetch(:block).call(self) end end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
2 3 4 |
# File 'lib/bootstrap_builders/panel.rb', line 2 def context @context end |
#controls ⇒ Object
Returns the value of attribute controls.
2 3 4 |
# File 'lib/bootstrap_builders/panel.rb', line 2 def controls @controls end |
Class Method Details
.with_parsed_args(*opts, &blk) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bootstrap_builders/panel.rb', line 4 def self.with_parsed_args(*opts, &blk) title = opts.shift unless opts.first.is_a?(Hash) width = opts.shift unless opts.first.is_a?(Hash) if opts.length == 1 && opts.first.is_a?(Hash) args = opts.first title = args.fetch(:title) if args.key?(:title) width = args[:width] if args.key?(:width) right = args[:right] if args.key?(:right) else args = {} end BootstrapBuilders::Panel.new(args.merge(title: title, width: width, right: right, block: blk)) end |
Instance Method Details
#html ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/bootstrap_builders/panel.rb', line 38 def html @panel = HtmlGen::Element.new(:div, inden: " ", classes: container_classes, css: @css, data: @data) generate_body add_heading if heading? add_body add_heading_controls html = @panel.html if html.respond_to?(:html_safe) html.html_safe else html end end |