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.
659 660 661 662 663 |
# File 'lib/wee/html_brushes.rb', line 659 def initialize(canvas) @name = canvas.register_callback(:input, self) @callbacks = {} @ids = Wee::IdGenerator::Sequential.new end |
Instance Method Details
#add_callback(callback) ⇒ Object
665 666 667 668 669 |
# File 'lib/wee/html_brushes.rb', line 665 def add_callback(callback) value = @ids.next.to_s @callbacks[value] = callback return [@name, value] end |
#call(value) ⇒ Object
671 672 673 674 675 676 677 678 |
# File 'lib/wee/html_brushes.rb', line 671 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 |