Sha256: f763949ed91466c8d5d5464f055f333720e378f609422760e4001df154e5ed6c

Contents?: true

Size: 682 Bytes

Versions: 6

Compression:

Stored size: 682 Bytes

Contents

module Tabulous
  class Tabset

    def initialize
      @tabs = []
    end

    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

    def tabs
      @tabs
    end

    def primary_tabs
      @tabs.reject(&:subtab?)
    end

    def active_primary_tab(view)
      for tab in primary_tabs
        return tab if tab.active?(view)
      end
      nil
    end

    def visible_subtabs(view)
      if active_primary_tab(view).nil?
        []
      else
        active_primary_tab(view).subtabs.select{|subtab| subtab.visible?(view)}
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tabulous-2.1.4 lib/tabulous/tabset.rb
tabulous-2.1.3 lib/tabulous/tabset.rb
tabulous-2.1.2 lib/tabulous/tabset.rb
tabulous-2.1.1 lib/tabulous/tabset.rb
tabulous-2.1.0 lib/tabulous/tabset.rb
tabulous-2.0.0 lib/tabulous/tabset.rb