Class: MPD::Controller::Channels::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/mpd/controller/channels.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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_messageObject



33
34
35
36
# File 'lib/mpd/controller/channels.rb', line 33

def read_message
	@channels.send :read_messages, true while @buffer.empty?
	@buffer.shift
end

#read_message_nonblockObject



38
39
40
41
# File 'lib/mpd/controller/channels.rb', line 38

def read_message_nonblock
	@channels.send :read_messages
	@buffer.shift
end

#send_message(text) ⇒ Object



29
30
31
# File 'lib/mpd/controller/channels.rb', line 29

def send_message (text)
	@channels.send_message(@name, text)
end