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.



143
144
145
146
# File 'lib/ruby_native/helper.rb', line 143

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

Instance Method Details

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



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

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



158
159
160
# File 'lib/ruby_native/helper.rb', line 158

def to_html
  @context.safe_join(@items)
end