Class: Nesta::Menu

Inherits:
Object
  • Object
show all
Defined in:
lib/nesta/models.rb

Constant Summary collapse

INDENT =
" " * 2

Class Method Summary collapse

Class Method Details

.for_path(path) ⇒ Object



321
322
323
324
325
326
327
328
# File 'lib/nesta/models.rb', line 321

def self.for_path(path)
  path.sub!(Regexp.new('^/'), '')
  if path.empty?
    full_menu
  else
    find_menu_item_by_path(full_menu, path)
  end
end

.full_menuObject



308
309
310
311
312
313
314
315
# File 'lib/nesta/models.rb', line 308

def self.full_menu
  menu = []
  menu_file = Nesta::Config.content_path('menu.txt')
  if File.exist?(menu_file)
    File.open(menu_file) { |file| append_menu_item(menu, file, 0) }
  end
  menu
end

.top_levelObject



317
318
319
# File 'lib/nesta/models.rb', line 317

def self.top_level
  full_menu.reject { |item| item.is_a?(Array) }
end