Class: LesliView::Components::Tabs::TabComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- LesliView::Components::Tabs::TabComponent
- Defined in:
- lib/lesli_view/components/tabs.rb
Instance Attribute Summary collapse
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#tab_id ⇒ Object
readonly
Returns the value of attribute tab_id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(id: nil, title: nil, icon: nil) ⇒ TabComponent
constructor
A new instance of TabComponent.
- #set_tab_id(tab_id, index) ⇒ Object
Constructor Details
#initialize(id: nil, title: nil, icon: nil) ⇒ TabComponent
Returns a new instance of TabComponent.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/lesli_view/components/tabs.rb', line 29 def initialize(id:nil, title: nil, icon: nil) @tab_id = nil if title @tab_id = title .downcase # string to lowercase .gsub(/[^0-9A-Za-z\s\-\_]/, '') # remove special characters from string .gsub(/_/, '-') # replace underscores with dashes .gsub(/\s+/, '-') # replace spaces or spaces with single dash end if id @tab_id = id end @title = title @icon = icon end |
Instance Attribute Details
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
27 28 29 |
# File 'lib/lesli_view/components/tabs.rb', line 27 def icon @icon end |
#tab_id ⇒ Object (readonly)
Returns the value of attribute tab_id.
27 28 29 |
# File 'lib/lesli_view/components/tabs.rb', line 27 def tab_id @tab_id end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
27 28 29 |
# File 'lib/lesli_view/components/tabs.rb', line 27 def title @title end |
Instance Method Details
#call ⇒ Object
53 54 55 |
# File 'lib/lesli_view/components/tabs.rb', line 53 def call content_tag :div, content end |
#set_tab_id(tab_id, index) ⇒ Object
49 50 51 |
# File 'lib/lesli_view/components/tabs.rb', line 49 def set_tab_id(tab_id, index) @tab_id = tab_id || "tab-#{index}" end |