Class: MPD::Controller::Toggle
- Inherits:
-
Object
- Object
- MPD::Controller::Toggle
- Defined in:
- lib/mpd/controller/toggle.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
-
#initialize(controller) ⇒ Toggle
constructor
A new instance of Toggle.
- #off(name) ⇒ Object
- #on(name) ⇒ Object
- #on?(name) ⇒ Boolean
- #pause? ⇒ Boolean
- #toggle(name) ⇒ Object
Constructor Details
#initialize(controller) ⇒ Toggle
Returns a new instance of Toggle.
16 17 18 |
# File 'lib/mpd/controller/toggle.rb', line 16 def initialize (controller) @controller = controller end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
14 15 16 |
# File 'lib/mpd/controller/toggle.rb', line 14 def controller @controller end |
Instance Method Details
#off(name) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/mpd/controller/toggle.rb', line 32 def off (name) if on? name controller.do_and_raise_if_needed name, false end self end |
#on(name) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/mpd/controller/toggle.rb', line 24 def on (name) unless on? name controller.do_and_raise_if_needed name, true end self end |
#on?(name) ⇒ Boolean
40 41 42 |
# File 'lib/mpd/controller/toggle.rb', line 40 def on? (name) controller.status.__send__ "#{name}?" end |
#pause? ⇒ Boolean
62 63 64 |
# File 'lib/mpd/controller/toggle.rb', line 62 def pause? controller.status == :pause end |
#toggle(name) ⇒ Object
20 21 22 |
# File 'lib/mpd/controller/toggle.rb', line 20 def toggle (name) controller.do_and_raise_if_needed name, !on?(name) end |