Verity: you seem rather stressed and confused. Perhaps take a step back and think about what you want your program to do; perhaps even write a short test for it. That way it'll be easier to reason about it, because you'll be able to say "I have this code, and I expect exactly this output".
it's hard for us to know what you expect without a concrete example of what you have and what output you desire
Verity: instead of wrestling with Ruby as a language, try to think about your problem -- ask rather "How do I reverse a string in Ruby?" than "How can I make sure that one byte comes after another if I am modifying an array of bytes in-place?" -- XY issues.
and I apologise if I sound condescending; I am trying to offer advice on getting efficient assistance.
grillon: since each proper project will declare what gems and what gem versions it depends on, my guess is it's better to leave the gem stuff to ruby and not try to shoehorn that into something else