/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
- module Widgets
- class Tabnav
- include CssTemplate
- attr_accessor :tabs, :html, :name
-
- def initialize(name, opts={})
- @name = name || :main
- @tabs = []
- @generate_css = opts[:generate_css] || false
- @html = opts[:html] || {} # setup default html options
- @html[:id] ||= name.to_s.underscore << '_tabnav'
- @html[:class] ||= @html[:id]
- end
-
- # should the helper generate a css for this tabnav?
- def generate_css?
- @generate_css ? true : false
- end
-
- # sort your tabs alphabetically
- def sort!
- @tabs.sort! { |x,y| x.name <=> y.name }
- end
-
- end
- end