Thanks, now i have an Array with all my fields, but if i want these
values in a meaningful Hash?
Are you sure you want a Hash ? Perhaps a Struct class would work
better. It's very easy to turn arrays into structs. Here's an
example where I created a Struct class with some named members, then
turned an array into a struct, then recovered the members of the
original array by examining the members of the struct.
$ irb
irb(main):001:0> class Foo < Struct.new
x,:y,:z) ; end
=> nil
irb(main):002:0> arr = [ :foo, "bar", 23, ]
=> [:foo, "bar", 23]
irb(main):003:0> struct = Foo.new(*arr)
=> #<struct Foo x=:foo, y="bar", z=23>
irb(main):004:0> struct.x
=> :foo
irb(main):005:0> struct.y
=> "bar"
irb(main):006:0> struct.z
=> 23
irb(main):007:0>
You can also access struct members in the same way as Arrays and
Hashes: struct[:x] is the same as struct.x .
Hope this helps,
Jeremy Henty