class Bootstrap4Helper::Spinner
Builds a simple CSS spinner component.
Public Class Methods
new(template, opts = {}, &block)
click to toggle source
Class constructor
@note The different support types are: `:border` and `:grow`
@param [ActionView] template @param [Hash] opts @option opts [Symbol] :type @option opts [String] :id @option opts [String] :class @option opts [Hash] :data
Calls superclass method
Bootstrap4Helper::Component::new
# File lib/bootstrap4_helper/spinner.rb, line 17 def initialize(template, opts = {}, &block) super(template) @type = opts.fetch(:type, :border) @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 representation of the object.
@return [String]
# File lib/bootstrap4_helper/spinner.rb, line 31 def to_s content_tag( :span, id: @id, class: "spinner-#{@type} #{@class}", role: 'status', aria: { hidden: true }, data: @data ) do content_tag :span, 'Loading', class: 'sr-only' end end