Class: Bootstrap4Helper::Badge
- Defined in:
- lib/bootstrap4_helper/badge.rb
Overview
Creates Bootstrap badge components that can be used anywhere.
Instance Method Summary collapse
-
#initialize(template, context_or_options = nil, opts = {}, &block) ⇒ Badge
constructor
Class constructor.
-
#to_s ⇒ Object
String representation of the object.
Methods inherited from Component
#capture, #concat, #config, #content_tag, #parse_arguments, #uuid
Constructor Details
#initialize(template, context_or_options = nil, opts = {}, &block) ⇒ Badge
Class constructor
12 13 14 15 16 17 18 19 |
# File 'lib/bootstrap4_helper/badge.rb', line 12 def initialize(template, = nil, opts = {}, &block) super(template) @context, args = parse_arguments(, opts) @id = args.fetch(:id, nil) @class = args.fetch(:class, '') @content = block || proc { '' } end |
Instance Method Details
#to_s ⇒ Object
String representation of the object.
24 25 26 |
# File 'lib/bootstrap4_helper/badge.rb', line 24 def to_s content_tag(config(:badge, :span), id: @id, class: container_class) { @content.call(self) } end |