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.



161
162
163
164
# File 'lib/ruby_native/helper.rb', line 161

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

Instance Method Details

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



166
167
168
169
170
171
172
173
# File 'lib/ruby_native/helper.rb', line 166

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



175
176
177
# File 'lib/ruby_native/helper.rb', line 175

def to_html
  @context.safe_join(@items)
end