Class: MenuBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/extensions/menu.rb

Instance Method Summary collapse

Constructor Details

#initializeMenuBuilder

Returns a new instance of MenuBuilder.



4
5
6
# File 'lib/sinatra/extensions/menu.rb', line 4

def initialize
  @elements = []
end

Instance Method Details

#buildObject



23
24
25
# File 'lib/sinatra/extensions/menu.rb', line 23

def build
  @elements
end


8
9
10
11
# File 'lib/sinatra/extensions/menu.rb', line 8

def dropdown(text,icon,submenu)
  @elements << { :type => 'dropdown' , :text => text, :icon => icon, :link => submenu }
  return self
end


13
14
15
16
# File 'lib/sinatra/extensions/menu.rb', line 13

def link(text,icon,link,target)
  @elements << { :type => 'link' , :text => text, :icon => icon, :link => link, :target => target }
  return self
end


18
19
20
21
# File 'lib/sinatra/extensions/menu.rb', line 18

def modal(text,icon,link)
  @elements << { :type => 'modal' , :text => text, :icon => icon, :link => link }
  return self
end