Robert Klemme
6/15/2008 9:34:00 AM
On 15.06.2008 11:08, Lucas L. wrote:
> Todd Benson wrote:
>> On Sun, Jun 15, 2008 at 12:16 AM, Lucas L. <lucaslevin@gmail.com> wrote:
>>
>>> How can I replace portions of a packed binary string this way?
>>> I know with a normal string it is easy:
>>> irb(main):001:0> s = "abcdef"
>>> => "abcdef"
>>> irb(main):002:0> s[0..2] = "cba"
>>> => "cba"
>>> irb(main):003:0> s
>>> => "cbadef"
>>>
>>> But I can't figure out how to do it with binary.
>> Look closely at Robert's irb line number 9.
>>
>> A string is just bytes in a row with special characteristics/methods.
>
> You'll have to bear with me on this, I struggle with this sort of this.
> I don't really know what using | achieves.
It's the bitwise OR operator.
irb(main):001:0> 1 | 2
=> 3
> And a string may be bytes normally, but mine is a sequence of bits (well
> is it in my flawed understanding). I'm using Gtk::Pixbuf.pixels, if that
> helps at all.
I do not know what Gtk::Pixbuf.pixels returns. But if it is a String
you can manipulate it like was have show before. Can you post what "p
your_pixbuf.pixels" and "p your_pixbuf.pixels.class" print?
Kind regards
robert