Method: Utel::Pdu.encode
- Defined in:
- lib/utel/pdu.rb
.encode(string) ⇒ Object
Encode and decode pdu strings
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/utel/pdu.rb', line 4 def self.encode string out = '' for i in (0..string.length - 1) do t = i%8+1 next if t == 8 c = string[i] >> i%8 b = (string[i+1] || 0) & ((1 << t)-1) c = (b << (8-t)) | c out << c.to_s(16).rjust(2, '0').upcase end out end |