Class: Tabulous::Tabset
- Inherits:
-
Object
- Object
- Tabulous::Tabset
- Defined in:
- lib/tabulous/tabset.rb
Instance Method Summary collapse
- #active_primary_tab(view) ⇒ Object
- #add_tab(tab) ⇒ Object
-
#initialize ⇒ Tabset
constructor
A new instance of Tabset.
- #primary_tabs ⇒ Object
- #tabs ⇒ Object
- #visible_subtabs(view) ⇒ Object
Constructor Details
#initialize ⇒ Tabset
Returns a new instance of Tabset.
4 5 6 |
# File 'lib/tabulous/tabset.rb', line 4 def initialize @tabs = [] end |
Instance Method Details
#active_primary_tab(view) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/tabulous/tabset.rb', line 23 def active_primary_tab(view) for tab in primary_tabs return tab if tab.active?(view) end nil end |
#add_tab(tab) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/tabulous/tabset.rb', line 8 def add_tab(tab) if @tabs.map(&:name).include?(tab.name) raise TabNameError, "There is already a tab named '#{tab.name}'." end @tabs << tab end |
#primary_tabs ⇒ Object
19 20 21 |
# File 'lib/tabulous/tabset.rb', line 19 def primary_tabs @tabs.reject(&:subtab?) end |
#tabs ⇒ Object
15 16 17 |
# File 'lib/tabulous/tabset.rb', line 15 def tabs @tabs end |
#visible_subtabs(view) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/tabulous/tabset.rb', line 30 def visible_subtabs(view) if active_primary_tab(view).nil? [] else active_primary_tab(view).subtabs.select{|subtab| subtab.visible?(view)} end end |