Class: Tabulatr::Data::ButtonBuilder
- Inherits:
-
Object
- Object
- Tabulatr::Data::ButtonBuilder
- Defined in:
- lib/tabulatr/data/button_builder.rb
Instance Method Summary collapse
- #button(icon, path, options = {}) ⇒ Object
- #divider ⇒ Object
-
#initialize ⇒ ButtonBuilder
constructor
A new instance of ButtonBuilder.
- #submenu {|_self| ... } ⇒ Object
- #val ⇒ Object
Constructor Details
#initialize ⇒ ButtonBuilder
Returns a new instance of ButtonBuilder.
37 38 39 40 41 42 |
# File 'lib/tabulatr/data/button_builder.rb', line 37 def initialize @mode = :buttons @buttons = [] @submenu = [] val end |
Instance Method Details
#button(icon, path, options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/tabulatr/data/button_builder.rb', line 48 def (icon, path, ={}) label = .dup.delete(:label) if @mode == :buttons @buttons << {icon: icon, path: path, options: } else @submenu << {icon: icon, label: label, path: path, options: } end val end |
#divider ⇒ Object
66 67 68 69 70 |
# File 'lib/tabulatr/data/button_builder.rb', line 66 def divider raise "use dividers only in submenu" unless @mode == :submenu @submenu << :divider val end |
#submenu {|_self| ... } ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/tabulatr/data/button_builder.rb', line 58 def (&block) raise "No submenus in submenus, sorry" if @mode == :submenu @mode = :submenu yield(self) @mode = :buttons val end |
#val ⇒ Object
44 45 46 |
# File 'lib/tabulatr/data/button_builder.rb', line 44 def val {buttons: @buttons, submenu: @submenu} end |