PageRenderTime 36ms CodeModel.GetById 32ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/widgets/tabnav.rb

http://github.com/paolodona/rails-widgets
Ruby | 26 lines | 20 code | 4 blank | 2 comment | 3 complexity | 25c43737d75517bfad93bc4fd29890c0 MD5 | raw file
Possible License(s): MIT
 1module Widgets 
 2  class Tabnav 
 3    include CssTemplate
 4    attr_accessor :tabs, :html, :name
 5        
 6    def initialize(name, opts={})
 7      @name = name || :main
 8      @tabs = []
 9      @generate_css = opts[:generate_css] || false
10      @html = opts[:html] || {} # setup default html options
11      @html[:id] ||= name.to_s.underscore << '_tabnav'
12      @html[:class] ||= @html[:id]
13    end
14     
15    # should the helper generate a css for this tabnav?
16    def generate_css?
17      @generate_css ? true : false
18    end
19   
20    # sort your tabs alphabetically
21    def sort!
22      @tabs.sort! { |x,y| x.name <=> y.name  }
23    end
24    
25  end
26end