Class: Moc::Protocol::Event

Inherits:
Symbol
  • Object
show all
Defined in:
lib/moc/protocol/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Symbol

#==, #initialize, #pack, read, #to_i, #to_s, #to_sym

Methods included from Type

#read, #unpack

Constructor Details

This class inherits a constructor from Moc::Protocol::Symbol

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args, &block) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/moc/protocol/event.rb', line 54

def method_missing (id, *args, &block)
	if data.respond_to? id
		return data.__send__ id, *args, &block
	end

	super
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



48
49
50
# File 'lib/moc/protocol/event.rb', line 48

def data
  @data
end

Class Method Details

.codesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/moc/protocol/event.rb', line 14

def self.codes
	@codes ||= {
		STATE:        0x01,
		CTIME:        0x02,
		SRV_ERROR:    0x04,
		BUSY:         0x05,
		DATA:         0x06,
		BITRATE:      0x07,
		RATE:         0x08,
		CHANNELS:     0x09,
		EXIT:         0x0a,
		PONG:         0x0b,
		OPTIONS:      0x0c,
		SEND_PLIST:   0x0d,
		TAGS:         0x0e,
		STATUS_MSG:   0x0f,
		MIXER_CHANGE: 0x10,
		FILE_TAGS:    0x11,
		AVG_BITRATE:  0x12,
		AUDIO_START:  0x13,
		AUDIO_STOP:   0x14,

		PLIST_ADD:   0x50,
		PLIST_DEL:   0x51,
		PLIST_MOVE:  0x52,
		PLIST_CLEAR: 0x53,

		QUEUE_ADD:   0x54,
		QUEUE_DEL:   0x55,
		QUEUE_MOVE:  0x56,
		QUEUE_CLEAR: 0x57
	}
end

Instance Method Details

#inspectObject



62
63
64
# File 'lib/moc/protocol/event.rb', line 62

def inspect
	"#<#{self.class.name}: #{to_s}#{" #{data.inspect}" if data}>"
end

#respond_to_missing?(id, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/moc/protocol/event.rb', line 50

def respond_to_missing? (id, include_private = false)
	data.respond_to?(id, include_private)
end