Class: Bootstrap4Helper::Spinner
- Defined in:
- lib/bootstrap4_helper/spinner.rb
Overview
Builds a simple CSS spinner component.
Instance Method Summary collapse
-
#initialize(template, opts = {}, &block) ⇒ Spinner
constructor
Class constructor.
-
#to_s ⇒ String
String representation of the object.
Methods inherited from Component
#capture, #concat, #config, #content_tag, #parse_arguments, #uuid
Constructor Details
#initialize(template, opts = {}, &block) ⇒ Spinner
Note:
The different support types are: ‘:border` and `:grow`
Class constructor
17 18 19 20 21 22 23 24 25 |
# 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 |
Instance Method Details
#to_s ⇒ String
String representation of the object.
31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 |