Class: UnderOs::UI::Switch
- Inherits:
-
Input
- Object
- Input
- UnderOs::UI::Switch
- Defined in:
- lib/under_os/ui/switch.rb
Instance Method Summary collapse
- #checked ⇒ Object
- #checked=(flag) ⇒ Object
-
#initialize(options = {}) ⇒ Switch
constructor
A new instance of Switch.
- #value ⇒ Object
- #value=(value) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Switch
Returns a new instance of Switch.
4 5 6 7 8 |
# File 'lib/under_os/ui/switch.rb', line 4 def initialize(={}) super self.checked = [:checked] if [:checked] @_.addTarget self, action: :handle_change, forControlEvents:UIControlEventValueChanged end |
Instance Method Details
#checked ⇒ Object
18 19 20 |
# File 'lib/under_os/ui/switch.rb', line 18 def checked @_.on? end |
#checked=(flag) ⇒ Object
22 23 24 |
# File 'lib/under_os/ui/switch.rb', line 22 def checked=(flag) @_.setOn flag, animated: true end |
#value ⇒ Object
10 11 12 |
# File 'lib/under_os/ui/switch.rb', line 10 def value @_value end |
#value=(value) ⇒ Object
14 15 16 |
# File 'lib/under_os/ui/switch.rb', line 14 def value=(value) @_value = value # just saving it on the instance end |