Class: Qrack::Transport09::Frame
- Inherits:
-
Object
- Object
- Qrack::Transport09::Frame
show all
- Defined in:
- lib/qrack/transport/frame09.rb
Constant Summary
collapse
206
- ID =
0
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(payload = nil, channel = 0) ⇒ Frame
Returns a new instance of Frame.
26
27
28
|
# File 'lib/qrack/transport/frame09.rb', line 26
def initialize payload = nil, channel = 0
@channel, @payload = channel, payload
end
|
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
24
25
26
|
# File 'lib/qrack/transport/frame09.rb', line 24
def channel
@channel
end
|
#payload ⇒ Object
Returns the value of attribute payload.
24
25
26
|
# File 'lib/qrack/transport/frame09.rb', line 24
def payload
@payload
end
|
Class Method Details
.parse(buf) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/qrack/transport/frame09.rb', line 54
def self.parse buf
buf = Transport09::Buffer.new(buf) unless buf.is_a? Transport09::Buffer
buf. do
id, channel, payload, = buf.read(:octet, :short, :longstr, :octet)
Qrack::Transport09.const_get(@types[id]).new(payload, channel) if == FOOTER
end
end
|
Instance Method Details
#==(frame) ⇒ Object
48
49
50
51
52
|
# File 'lib/qrack/transport/frame09.rb', line 48
def == frame
[ :id, :channel, :payload ].inject(true) do |eql, field|
eql and __send__(field) == frame.__send__(field)
end
end
|
#id ⇒ Object
30
31
32
|
# File 'lib/qrack/transport/frame09.rb', line 30
def id
self.class::ID
end
|
#to_binary ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/qrack/transport/frame09.rb', line 34
def to_binary
buf = Transport09::Buffer.new
buf.write :octet, id
buf.write :short, channel
buf.write :longstr, payload
buf.write :octet, FOOTER
buf.rewind
buf
end
|
#to_s ⇒ Object
44
45
46
|
# File 'lib/qrack/transport/frame09.rb', line 44
def to_s
to_binary.to_s
end
|