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.
612 613 614 615 616 |
# File 'lib/wee/html_brushes.rb', line 612 def initialize(canvas) @name = canvas.register_callback(:input, self) @callbacks = {} @ids = Wee::IdGenerator::Sequential.new end |
Instance Method Details
#add_callback(callback) ⇒ Object
618 619 620 621 622 |
# File 'lib/wee/html_brushes.rb', line 618 def add_callback(callback) value = @ids.next.to_s @callbacks[value] = callback return [@name, value] end |
#call(value) ⇒ Object
624 625 626 627 628 629 630 631 |
# File 'lib/wee/html_brushes.rb', line 624 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 |