Class: ReverseTunnel::Message::Unpacker
- Inherits:
-
Object
- Object
- ReverseTunnel::Message::Unpacker
- Includes:
- Enumerable
- Defined in:
- lib/reverse-tunnel/message.rb
Instance Attribute Summary collapse
-
#unpacker ⇒ Object
readonly
Returns the value of attribute unpacker.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #feed(data) ⇒ Object
-
#initialize ⇒ Unpacker
constructor
A new instance of Unpacker.
Constructor Details
#initialize ⇒ Unpacker
Returns a new instance of Unpacker.
42 43 44 |
# File 'lib/reverse-tunnel/message.rb', line 42 def initialize @unpacker = MessagePack::Unpacker.new end |
Instance Attribute Details
#unpacker ⇒ Object (readonly)
Returns the value of attribute unpacker.
40 41 42 |
# File 'lib/reverse-tunnel/message.rb', line 40 def unpacker @unpacker end |
Instance Method Details
#each(&block) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/reverse-tunnel/message.rb', line 51 def each(&block) unpacker.each do |data| type_id = data.shift payload = data Message.create(type_id).tap do || .load(payload) yield end end end |
#feed(data) ⇒ Object
46 47 48 |
# File 'lib/reverse-tunnel/message.rb', line 46 def feed(data) unpacker.feed data end |