Class: MenuBar::AbstractContent
- Inherits:
-
Object
- Object
- MenuBar::AbstractContent
- Includes:
- EasyMenu::Helpers
- Defined in:
- lib/menu_bar.rb
Overview
ABSTRACT CLASSES
Direct Known Subclasses
AbstractItem, Menu, MenuBarContent, MenuBarInput, MenuContent
Constant Summary
Constants included from EasyMenu::Helpers
EasyMenu::Helpers::HTML_OPTIONS
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(config, content, options = {}) ⇒ AbstractContent
constructor
A new instance of AbstractContent.
- #right_aligned? ⇒ Boolean
- #to_s ⇒ Object
Methods included from EasyMenu::Helpers
#config_name, #css_class, #html_option_keys, #merge_class, #wrap_content, #wrapper_element
Constructor Details
#initialize(config, content, options = {}) ⇒ AbstractContent
Returns a new instance of AbstractContent.
160 161 162 163 164 165 166 |
# File 'lib/menu_bar.rb', line 160 def initialize(config, content, = {}) raise if config[:template].is_a?(Hash) || config[:template].nil? @config = config @template = config[:template] @content = Array(content) @options = end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
159 160 161 |
# File 'lib/menu_bar.rb', line 159 def config @config end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
159 160 161 |
# File 'lib/menu_bar.rb', line 159 def content @content end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
159 160 161 |
# File 'lib/menu_bar.rb', line 159 def @options end |
Instance Method Details
#empty? ⇒ Boolean
168 169 170 |
# File 'lib/menu_bar.rb', line 168 def empty? @content.all?(&:blank?) end |
#right_aligned? ⇒ Boolean
176 177 178 |
# File 'lib/menu_bar.rb', line 176 def right_aligned? [:align].to_s == 'right' end |
#to_s ⇒ Object
172 173 174 |
# File 'lib/menu_bar.rb', line 172 def to_s empty? ? '' : wrap_content(@content.join.html_safe) # Don't render anything if empty end |