Class: OSC::Packet::PO

Inherits:
Object show all
Defined in:
lib/osc-ruby/packet.rb

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ PO

Returns a new instance of PO.



5
6
7
# File 'lib/osc-ruby/packet.rb', line 5

def initialize(str) 
  @str, @index = str, 0 
end

Instance Method Details

#eof?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/osc-ruby/packet.rb', line 13

def eof? () 
  rem <= 0 
end

#getcObject

Raises:

  • (EOFError)


32
33
34
35
36
37
# File 'lib/osc-ruby/packet.rb', line 32

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

#getn(n) ⇒ Object

Raises:

  • (EOFError)


25
26
27
28
29
30
# File 'lib/osc-ruby/packet.rb', line 25

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

#remObject



9
10
11
# File 'lib/osc-ruby/packet.rb', line 9

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

#skip(n) ⇒ Object



17
18
19
# File 'lib/osc-ruby/packet.rb', line 17

def skip(n) 
  @index += n 
end

#skip_paddingObject



21
22
23
# File 'lib/osc-ruby/packet.rb', line 21

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