Class: Stomp::HeaderCodec
- Inherits:
-
Object
- Object
- Stomp::HeaderCodec
- Defined in:
- lib/stomp/codec.rb
Overview
Purpose
A general CODEC for STOMP 1.1 header keys and values.
See:
for encode/decode rules.
Class Method Summary collapse
-
.decode(in_string = nil) ⇒ Object
decode decodes header data per the STOMP 1.1 specification.
-
.encode(in_string = nil) ⇒ Object
encode encodes header data per the STOMP 1.1 specification.
Class Method Details
.decode(in_string = nil) ⇒ Object
decode decodes header data per the STOMP 1.1 specification.
31 32 33 34 35 36 37 38 39 |
# File 'lib/stomp/codec.rb', line 31 def self.decode(in_string = nil) return in_string unless in_string ev = Stomp::DECODE_VALUES # avoid typing below os = in_string + "" 0.step(ev.length-2,2) do |i| # [encoded, decoded] os.gsub!(ev[i], ev[i+1]) end os end |
.encode(in_string = nil) ⇒ Object
encode encodes header data per the STOMP 1.1 specification.
20 21 22 23 24 25 26 27 28 |
# File 'lib/stomp/codec.rb', line 20 def self.encode(in_string = nil) return in_string unless in_string ev = Stomp::ENCODE_VALUES # avoid typing below os = in_string + "" 0.step(ev.length-2,2) do |i| # [encoded, decoded] os.gsub!(ev[i+1], ev[i]) end os end |