Sha256: 531b063ee8ba7ba095c6a7bc6fd1e65b53c537697429bfab6db5490849829b83

Contents?: true

Size: 556 Bytes

Versions: 4

Compression:

Stored size: 556 Bytes

Contents

module OSC
  class NetworkPacket
    def initialize(str)
      @str, @index = str.force_encoding("BINARY"), 0
    end

    def to_s
      @str
    end

    def rem()
      @str.length - @index
    end

    def eof? ()
      rem <= 0
    end

    def skip(n)
      @index += n
    end

    def skip_padding()
      skip((4 - (@index % 4)) % 4)
    end

    def getn(n)
    	raise EOFError if rem < n
    	s = @str[@index, n]
    	skip(n)
    	s
    end

    def getc
    	raise EOFError if rem < 1
    	c = @str[@index]
    	skip(1)
    	c
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
osc-ruby-1.1.3 lib/osc-ruby/network_packet.rb
osc-ruby-1.1.2 lib/osc-ruby/network_packet.rb
osc-ruby-1.1.1 lib/osc-ruby/network_packet.rb
osc-ruby-1.1.0 lib/osc-ruby/network_packet.rb