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



372
373
374
375
376
377
378
379
# File 'lib/nesta/models.rb', line 372

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



359
360
361
362
363
364
365
366
# File 'lib/nesta/models.rb', line 359

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



368
369
370
# File 'lib/nesta/models.rb', line 368

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