Class: MPD::Controller::Channels::Channel
- Inherits:
-
Object
- Object
- MPD::Controller::Channels::Channel
- Defined in:
- lib/mpd/controller/channels.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #incoming(text) ⇒ Object
-
#initialize(channels, name) ⇒ Channel
constructor
A new instance of Channel.
- #read_message ⇒ Object
- #read_message_nonblock ⇒ Object
- #send_message(text) ⇒ Object
Constructor Details
#initialize(channels, name) ⇒ Channel
Returns a new instance of Channel.
19 20 21 22 23 |
# File 'lib/mpd/controller/channels.rb', line 19 def initialize (channels, name) @channels = channels @name = name @buffer = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/mpd/controller/channels.rb', line 17 def name @name end |
Instance Method Details
#incoming(text) ⇒ Object
25 26 27 |
# File 'lib/mpd/controller/channels.rb', line 25 def incoming (text) @buffer << text end |
#read_message ⇒ Object
33 34 35 36 |
# File 'lib/mpd/controller/channels.rb', line 33 def @channels.send :read_messages, true while @buffer.empty? @buffer.shift end |
#read_message_nonblock ⇒ Object
38 39 40 41 |
# File 'lib/mpd/controller/channels.rb', line 38 def @channels.send :read_messages @buffer.shift end |
#send_message(text) ⇒ Object
29 30 31 |
# File 'lib/mpd/controller/channels.rb', line 29 def (text) @channels.(@name, text) end |