Class: MenuBar::Menu
- Inherits:
-
AbstractContent
- Object
- AbstractContent
- MenuBar::Menu
- Defined in:
- lib/menu_bar.rb
Direct Known Subclasses
Constant Summary
Constants included from EasyMenu::Helpers
EasyMenu::Helpers::HTML_OPTIONS
Instance Attribute Summary
Attributes inherited from AbstractContent
Instance Method Summary collapse
- #group(title, options = {}) {|mg| ... } ⇒ Object
-
#initialize(config, options = {}) {|_self| ... } ⇒ Menu
constructor
A new instance of Menu.
- #menu_content(content = nil, options = {}, &block) ⇒ Object
- #menu_item(content, options = {}) ⇒ Object
- #separator(options = {}) ⇒ Object
Methods inherited from AbstractContent
#empty?, #right_aligned?, #to_s
Methods included from EasyMenu::Helpers
#config_name, #css_class, #html_option_keys, #merge_class, #wrap_content, #wrapper_element
Constructor Details
#initialize(config, options = {}) {|_self| ... } ⇒ Menu
Returns a new instance of Menu.
277 278 279 280 281 282 283 284 285 286 |
# File 'lib/menu_bar.rb', line 277 def initialize(config, = {}) raise if config[:template].is_a?(Hash) || config[:template].nil? @config = config @template = config[:template] @options = @content = [] yield self if block_given? end |
Instance Method Details
#group(title, options = {}) {|mg| ... } ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/menu_bar.rb', line 288 def group(title, = {}) () mgt = @template.content_tag(config[:menu_group_title_element], title, merge_class([:menu_group_title], config[:menu_group_title_class])) mg = MenuGroup.new(config, ) yield mg if block_given? mc = MenuContent.new(config, [mgt, mg], [:menu_content]) (mc, ) return mg end |
#menu_content(content = nil, options = {}, &block) ⇒ Object
303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/menu_bar.rb', line 303 def (content = nil, = {}, &block) () if block_given? = content || content = block.call end mc = MenuContent.new(config, content, ) (mc, ) end |
#menu_item(content, options = {}) ⇒ Object
316 317 318 319 320 321 322 323 324 325 |
# File 'lib/menu_bar.rb', line 316 def (content, = {}) () mi = MenuItem.new(config, content, ) mc = MenuContent.new(config, mi, [:menu_content]) (mc, ) return mi end |
#separator(options = {}) ⇒ Object
327 328 329 330 331 332 333 334 |
# File 'lib/menu_bar.rb', line 327 def separator( = {}) s = @template.content_tag :div, '', :class => config[:menu_separator_class] mc = MenuContent.new(config, s) (mc, ) return s end |