class Fidgit::Group
Attributes
selected[R]
Public Class Methods
new(options = {}, &block)
click to toggle source
@example
group do horizontal do radio_button 1, text: '1', checked: true radio_button 2, text: '2' subscribe :changed do |sender, value| puts value end end end
@param (see Packer#initialize)
@option (see Packer#initialize)
Calls superclass method
# File lib/fidgit/elements/group.rb, line 23 def initialize(options = {}, &block) super(options) @selected = nil @buttons = [] end
Public Instance Methods
value()
click to toggle source
# File lib/fidgit/elements/group.rb, line 7 def value; @selected ? @selected.value : nil; end
value=(value)
click to toggle source
@example
@my_group = group do horizontal do radio_button(1, text: '1', checked: true) radio_button(2, text: '2') end end # later @my_group.value = 2
# File lib/fidgit/elements/group.rb, line 52 def value=(value) if value != self.value button = @buttons.find { |b| b.value == value } @selected.uncheck if @selected and @selected.checked? @selected = button @selected.check if @selected and not @selected.checked? publish :changed, self.value end value end