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.



141
142
143
144
# File 'lib/ruby_native/helper.rb', line 141

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

Instance Method Details

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



146
147
148
149
150
151
152
153
154
# File 'lib/ruby_native/helper.rb', line 146

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

#to_htmlObject



156
157
158
# File 'lib/ruby_native/helper.rb', line 156

def to_html
  @context.safe_join(@items)
end