Class: MenuBar::AbstractContent

Inherits:
Object
  • Object
show all
Includes:
EasyMenu::Helpers
Defined in:
lib/menu_bar.rb

Overview

ABSTRACT CLASSES

Constant Summary

Constants included from EasyMenu::Helpers

EasyMenu::Helpers::HTML_OPTIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  raise if config[:template].is_a?(Hash) || config[:template].nil?
  @config = config
  @template = config[:template]
  @content = Array(content)
  @options = options
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



159
160
161
# File 'lib/menu_bar.rb', line 159

def config
  @config
end

#contentObject (readonly)

Returns the value of attribute content.



159
160
161
# File 'lib/menu_bar.rb', line 159

def content
  @content
end

#optionsObject (readonly)

Returns the value of attribute options.



159
160
161
# File 'lib/menu_bar.rb', line 159

def options
  @options
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


168
169
170
# File 'lib/menu_bar.rb', line 168

def empty?
  @content.all?(&:blank?)
end

#right_aligned?Boolean

Returns:

  • (Boolean)


176
177
178
# File 'lib/menu_bar.rb', line 176

def right_aligned?
  options[:align].to_s == 'right'
end

#to_sObject



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