Class: ActiveElement::Components::Tab

Inherits:
Object
  • Object
show all
Defined in:
lib/active_element/components/tab.rb

Overview

One navigation tab in a Tabs component.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content.



7
8
9
# File 'lib/active_element/components/tab.rb', line 7

def content
  @content
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/active_element/components/tab.rb', line 7

def path
  @path
end

#titleObject (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

#identifierObject



20
21
22
# File 'lib/active_element/components/tab.rb', line 20

def identifier
  Util::I18n.class_name(title)
end

#selected?Boolean

Returns:

  • (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

Yields:



28
29
30
# File 'lib/active_element/components/tab.rb', line 28

def tab(title)
  yield Tab.new(title)
end

#to_sObject



24
25
26
# File 'lib/active_element/components/tab.rb', line 24

def to_s
  ''
end