Class: Admin::BadgeComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Admin::BadgeComponent
- Defined in:
- lib/generators/infold/templates/install/app/components/admin/badge_component.rb
Instance Method Summary collapse
- #badge_class ⇒ Object
- #call ⇒ Object
-
#initialize(name, color) ⇒ BadgeComponent
constructor
A new instance of BadgeComponent.
Constructor Details
#initialize(name, color) ⇒ BadgeComponent
Returns a new instance of BadgeComponent.
5 6 7 8 |
# File 'lib/generators/infold/templates/install/app/components/admin/badge_component.rb', line 5 def initialize(name, color) @name = name @color = color end |
Instance Method Details
#badge_class ⇒ Object
10 11 12 |
# File 'lib/generators/infold/templates/install/app/components/admin/badge_component.rb', line 10 def badge_class "badge bg-#{@color}" if @color.present? end |
#call ⇒ Object
14 15 16 |
# File 'lib/generators/infold/templates/install/app/components/admin/badge_component.rb', line 14 def call "<span class=\"#{badge_class}\">#{@name}</span>".html_safe if @name.present? end |