Module: RocketAMF::Pure::IOHelperWrite
Overview
Instance Method Summary
collapse
#byte_order, #byte_order_little?
Instance Method Details
#pack_double(double) ⇒ Object
28
29
30
|
# File 'lib/rocketamf/pure/helpers/io_helper_write.rb', line 28
def pack_double(double)
[double].pack('G')
end
|
#pack_int16_network(val) ⇒ Object
36
37
38
|
# File 'lib/rocketamf/pure/helpers/io_helper_write.rb', line 36
def pack_int16_network(val)
[val].pack('n')
end
|
#pack_int8(val) ⇒ Object
32
33
34
|
# File 'lib/rocketamf/pure/helpers/io_helper_write.rb', line 32
def pack_int8(val)
[val].pack('c')
end
|
#pack_integer(integer) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/rocketamf/pure/helpers/io_helper_write.rb', line 9
def pack_integer(integer)
integer = integer & 0x1fffffff
if integer < 0x80
[integer].pack('c')
elsif integer < 0x4000
[integer >> 7 & 0x7f | 0x80].pack('c')+
[integer & 0x7f].pack('c')
elsif integer < 0x200000
[integer >> 14 & 0x7f | 0x80].pack('c') +
[integer >> 7 & 0x7f | 0x80].pack('c') +
[integer & 0x7f].pack('c')
else
[integer >> 22 & 0x7f | 0x80].pack('c')+
[integer >> 15 & 0x7f | 0x80].pack('c')+
[integer >> 8 & 0x7f | 0x80].pack('c')+
[integer & 0xff].pack('c')
end
end
|
#pack_word32_network(val) ⇒ Object
40
41
42
43
44
|
# File 'lib/rocketamf/pure/helpers/io_helper_write.rb', line 40
def pack_word32_network(val)
result = [val].pack('L')
result.reverse! if byte_order_little? result
end
|