Class: Bootstrap3Helper::Callout

Inherits:
Component show all
Defined in:
lib/bootstrap3_helper/callout.rb

Overview

Used to generate Bootstrap callout component quickly.

Instance Method Summary collapse

Methods inherited from Component

#concat, #content_tag, #parse_arguments, #uuid

Constructor Details

#initialize(template, context_or_options = nil, opts = {}, &block) ⇒ Callout

Parameters:

  • template (Class)
    • Template in which your are binding too.

  • - (NilClass|String|Symbol|Hash)

    Bootstrap class context, or options hash.

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :id (String)

    The ID of the element

  • :class (String)

    Custom class for the component.



13
14
15
16
17
18
19
20
# File 'lib/bootstrap3_helper/callout.rb', line 13

def initialize(template, context_or_options = nil, opts = {}, &block)
  super(template)
  @context, args = parse_arguments(context_or_options, opts)

  @id      = args.fetch(:id, nil)
  @class   = args.fetch(:class, '')
  @content = block || proc { '' }
end

Instance Method Details

#to_sString

Returns a string representation of the component.

Returns:

  • (String)


26
27
28
29
30
# File 'lib/bootstrap3_helper/callout.rb', line 26

def to_s
   :div, id: @id, class: container_class do
    @content.call(self)
  end
end