class Bootstrap4Helper::Dropdown
Builds a Dropdown
component that can be used in other components.
Public Class Methods
new(template, type = :dropdown, opts = {}, &block)
click to toggle source
Class constructor
@param [ActionView] template @param [Symbol|String] type @param [Hash] opts @option opts [String] :id @option opts [String] :class @option opts [Hash] :data
Calls superclass method
Bootstrap4Helper::Component::new
# File lib/bootstrap4_helper/dropdown.rb, line 15 def initialize(template, type = :dropdown, opts = {}, &block) super(template) @type = type @id = opts.fetch(:id, uuid) @class = opts.fetch(:class, '') @data = opts.fetch(:data, {}) @content = block || proc { '' } end
Public Instance Methods
to_s()
click to toggle source
String reprentation of the object.
@return [String]
# File lib/bootstrap4_helper/dropdown.rb, line 72 def to_s content_tag :div, id: @id, class: "#{container_class} #{@class}", data: @data do @content.call(self) end end
Private Instance Methods
container_class()
click to toggle source
Returns the container class for the dropdown component.
@return [String]
# File lib/bootstrap4_helper/dropdown.rb, line 84 def container_class case @type when :dropdown 'dropdown' when :group 'btn-group' else '' end end