Class: RubyNative::Helper::NavbarMenuBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_native/helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ NavbarMenuBuilder

Returns a new instance of NavbarMenuBuilder.



99
100
101
102
# File 'lib/ruby_native/helper.rb', line 99

def initialize(context)
  @context = context
  @items = []
end

Instance Method Details

#item(title, href: nil, click: nil, icon: nil, selected: false) ⇒ Object



104
105
106
107
108
109
110
111
# File 'lib/ruby_native/helper.rb', line 104

def item(title, href: nil, click: nil, icon: nil, selected: false)
  data = { native_menu_item: "", native_title: title }
  data[:native_href] = href if href
  data[:native_click] = click if click
  data[:native_icon] = icon if icon
  data[:native_selected] = "" if selected
  @items << @context.tag.div(data: data)
end

#to_htmlObject



113
114
115
# File 'lib/ruby_native/helper.rb', line 113

def to_html
  @context.safe_join(@items)
end