Class: ActiveElement::Components::Tab
- Inherits:
-
Object
- Object
- ActiveElement::Components::Tab
- Defined in:
- lib/active_element/components/tab.rb
Overview
One navigation tab in a Tabs component.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #identifier ⇒ Object
-
#initialize(controller, title:, path:, &block) ⇒ Tab
constructor
A new instance of Tab.
- #selected? ⇒ Boolean
- #tab(title) {|Tab.new(title)| ... } ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(controller, title:, path:, &block) ⇒ Tab
Returns a new instance of Tab.
9 10 11 12 13 14 |
# File 'lib/active_element/components/tab.rb', line 9 def initialize(controller, title:, path:, &block) @controller = controller @title = title @path = path @content = block_given? ? block.call : '' end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/active_element/components/tab.rb', line 7 def content @content end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/active_element/components/tab.rb', line 7 def path @path end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/active_element/components/tab.rb', line 7 def title @title end |
Instance Method Details
#identifier ⇒ Object
20 21 22 |
# File 'lib/active_element/components/tab.rb', line 20 def identifier Util::I18n.class_name(title) end |
#selected? ⇒ Boolean
16 17 18 |
# File 'lib/active_element/components/tab.rb', line 16 def selected? controller.request.fullpath == path end |
#tab(title) {|Tab.new(title)| ... } ⇒ Object
28 29 30 |
# File 'lib/active_element/components/tab.rb', line 28 def tab(title) yield Tab.new(title) end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/active_element/components/tab.rb', line 24 def to_s '' end |