Forum: Ruby on Rails Blobs

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
712498aa46736f08bb1686a2abccfb1c?d=identicon&s=25 Par Skoglund (perskog)
on 2007-07-16 19:27
Hi@All!

I completely new to RoR.

I have a table which looks like this:
[ id | width:int | height:int | data: blob ]

The blob contains a matrix of double precision values (64 bits).
Apparently RoR gives me a string when i read the blob. How do I convert
this string to a double matrix? Or rather, how do I turn 4 bytes into a
Float?

Thanks,
Par
C9c7a65848f13e2b1a226bbe43bc3672?d=identicon&s=25 Pete Yandell (pete)
on 2007-07-17 07:08
(Received via mailing list)
Par Skoglund wrote:

> Or rather, how do I turn 4 bytes into a
> Float?

You probably want to look at String.unpack and its opposite Array.pack.

Pete Yandell
http://notahat.com/
712498aa46736f08bb1686a2abccfb1c?d=identicon&s=25 Par Skoglund (perskog)
on 2007-07-17 12:16
Pete Yandell wrote:
> Par Skoglund wrote:
>
>> Or rather, how do I turn 4 bytes into a
>> Float?
>
> You probably want to look at String.unpack and its opposite Array.pack.
>
> Pete Yandell
> http://notahat.com/

upack did the trick.

Thanks a million, Pete!
This topic is locked and can not be replied to.