Class: SmppEncoding::Encoder
- Inherits:
-
Object
- Object
- SmppEncoding::Encoder
- Defined in:
- lib/smpp_encoding/encoder.rb
Constant Summary collapse
- ENCODING_GSM =
currently support only GSM and UNICODE
0
- ENCODING_UNICODE =
8
Instance Method Summary collapse
Instance Method Details
#auto_encode(message) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/smpp_encoding/encoder.rb', line 10 def auto_encode if GSMEncoder.can_encode?() { data_coding: ENCODING_GSM, payload: encode(ENCODING_GSM, ) } else { data_coding: ENCODING_UNICODE, payload: encode(ENCODING_UNICODE, ) } end end |
#enc(coding, message) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/smpp_encoding/encoder.rb', line 32 def enc coding, if coding == :auto res = auto_encode() [res[:payload], res[:data_coding]] else [encode(coding, ), coding] end end |
#encode(encoding, message) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/smpp_encoding/encoder.rb', line 24 def encode encoding, if (encoding < 2) GSMEncoder.encode() else .encode('UTF-16BE').force_encoding('binary') end end |