I have this code to split a string into groups of 3 bytes:
str="hello"
ix=0, iy=0
bytes=[]
tby=[]
str.each_byte do |c|
if iy==3
iy=0
bytes[ix]=[]
tby.each_index do |i|
bytes[ix][i]=tby[i]
end
ix+=1
end
tby[iy]=c
iy+=1
end
puts bytes
I've based it on this example: http://www.ruby-forum.com/topic/75570
However I'm getting type errors from it. Thanks.