Class: MPD::Controller::Channels
- Inherits:
-
Object
- Object
- MPD::Controller::Channels
- Includes:
- Enumerable
- Defined in:
- lib/mpd/controller/channels.rb
Defined Under Namespace
Classes: Channel
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
- #[](name, sub = true) ⇒ Object
- #each ⇒ Object
- #each_name(&block) ⇒ Object
-
#initialize(controller) ⇒ Channels
constructor
A new instance of Channels.
- #names ⇒ Object
- #send_message(name, text) ⇒ Object
- #subscribe(name) ⇒ Object
- #unsubscribe(name) ⇒ Object
Constructor Details
#initialize(controller) ⇒ Channels
Returns a new instance of Channels.
48 49 50 51 |
# File 'lib/mpd/controller/channels.rb', line 48 def initialize (controller) @controller = controller @channels = [] end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
46 47 48 |
# File 'lib/mpd/controller/channels.rb', line 46 def controller @controller end |
Instance Method Details
#[](name, sub = true) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/mpd/controller/channels.rb', line 71 def [] (name, sub = true) subscribe name if sub Channel.new(self, name).tap {|channel| @channels << WeakRef.new(channel) } end |
#each ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/mpd/controller/channels.rb', line 61 def each return to_enum unless block_given? each_name {|name| yield self[name] } self end |
#each_name(&block) ⇒ Object
57 58 59 |
# File 'lib/mpd/controller/channels.rb', line 57 def each_name (&block) names.each(&block) end |
#names ⇒ Object
53 54 55 |
# File 'lib/mpd/controller/channels.rb', line 53 def names controller.do_and_raise_if_needed(:channels).map(&:last) end |
#send_message(name, text) ⇒ Object
87 88 89 |
# File 'lib/mpd/controller/channels.rb', line 87 def (name, text) controller.do_and_raise_if_needed :sendmessage, name, text end |
#subscribe(name) ⇒ Object
79 80 81 |
# File 'lib/mpd/controller/channels.rb', line 79 def subscribe (name) controller.do_and_raise_if_needed :subscribe, name end |
#unsubscribe(name) ⇒ Object
83 84 85 |
# File 'lib/mpd/controller/channels.rb', line 83 def unsubscribe (name) controller.do_and_raise_if_needed :unsubscribe, name end |