Class: LightMobile::Tabs
- Inherits:
-
Object
- Object
- LightMobile::Tabs
- Defined in:
- lib/light_mobile/tabs.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ Tabs
constructor
A new instance of Tabs.
- #tab(args) ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(args) ⇒ Tabs
Returns a new instance of Tabs.
2 3 4 |
# File 'lib/light_mobile/tabs.rb', line 2 def initialize(args) @tabs = [] end |
Instance Method Details
#tab(args) ⇒ Object
6 7 8 |
# File 'lib/light_mobile/tabs.rb', line 6 def tab(args) @tabs << args end |
#to_html ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/light_mobile/tabs.rb', line 10 def to_html table = ::HtmlGen::Element.new(:table, classes: ["mobile-tabs"]) tr = table.add_ele(:tbody).add_ele(:tr) @tabs.each do |tab| td = tr.add(:td) td.classes << "mobile-tab-active" if tab[:active] td.data[:tab] = tab[:id] if tab[:icon] td.css["background-image"] = "url('#{tab[:icon]}')" td.classes << "mobile-tab-icon" end td.add_str tab[:label] if tab[:label] end table.html.html_safe end |