Sha256: 78470c1ab8b2b550d4a27a0d8f20ecd417f8d33a33183aca5e74902cbd6deb54

Contents?: true

Size: 927 Bytes

Versions: 9

Compression:

Stored size: 927 Bytes

Contents

module Tabulous

  class Tab
    
    attr_reader :name, :parent
    attr_accessor :subtabs
    
    def initialize(name, text, path, visible, enabled)
      @name = name
      name = name.to_s
      if name.ends_with? '_tab'
        @kind = :tab
      elsif name.ends_with? '_subtab'
        @kind = :subtab
      else
        raise TabNameError,
              "Incorrect tab name: '#{name}'.  Tab names must end with _tab or _subtab."
      end
      @text = text
      @path = path
      @visible = visible
      @enabled = enabled
      @subtabs = []
    end
    
    def add_parent(tab)
      @parent = tab
      @parent.subtabs = @parent.subtabs + [self]
    end
    
    def subtab?
      @kind == :subtab
    end
    
    def text(view)
      @text
    end
    
    def path(view)
      @path
    end
    
    def visible?(view)
      !!@visible
    end
    
    def enabled?(view)
      !!@enabled
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tabulous-1.3.2 lib/tabulous/tab.rb
tabulous-1.3.1 lib/tabulous/tab.rb
tabulous-1.3.0 lib/tabulous/tab.rb
tabulous-1.2.0 lib/tabulous/tab.rb
tabulous-1.1.0 lib/tabulous/tab.rb
tabulous-1.0.3 lib/tabulous/tab.rb
tabulous-1.0.2 lib/tabulous/tab.rb
tabulous-1.0.1 lib/tabulous/tab.rb
tabulous-1.0.0 lib/tabulous/tab.rb