Class: Syslog::Stream::OctetCountingFraming

Inherits:
Object
  • Object
show all
Defined in:
lib/syslog/stream/octet_counting_framing.rb

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ OctetCountingFraming

Returns a new instance of OctetCountingFraming.



4
5
6
# File 'lib/syslog/stream/octet_counting_framing.rb', line 4

def initialize(io)
  @io = io
end

Instance Method Details

#messagesObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/syslog/stream/octet_counting_framing.rb', line 8

def messages
  loop do
    length = ""
    octet = ""

    until octet == " " do
      if @io.read(1, octet) == nil
        return
      end

      length << octet
    end

    yield @io.read(Integer(length)).force_encoding("UTF-8")
  end
end