Class: Wee::Brush::RadioGroup
Overview
Form - Radio
Instance Method Summary collapse
- #add_callback(callback) ⇒ Object
- #call(value) ⇒ Object
-
#initialize(canvas) ⇒ RadioGroup
constructor
A new instance of RadioGroup.
Constructor Details
#initialize(canvas) ⇒ RadioGroup
Returns a new instance of RadioGroup.
613 614 615 616 617 |
# File 'lib/wee/html_brushes.rb', line 613 def initialize(canvas) @name = canvas.register_callback(:input, self) @callbacks = {} @ids = Wee::IdGenerator::Sequential.new end |
Instance Method Details
#add_callback(callback) ⇒ Object
619 620 621 622 623 |
# File 'lib/wee/html_brushes.rb', line 619 def add_callback(callback) value = @ids.next.to_s @callbacks[value] = callback return [@name, value] end |
#call(value) ⇒ Object
625 626 627 628 629 630 631 632 |
# File 'lib/wee/html_brushes.rb', line 625 def call(value) if @callbacks.has_key?(value) cb = @callbacks[value] cb.call(value) if cb else raise "invalid radio button/group value" end end |