On Wed, Jul 10, 2013 at 4:21 PM, stefan heinrich <lists / ruby-forum.com>wrote:

> Hi Robert and Marcus,
>
> thanks for your help. Both methods are working very fine :D.
> But now I have the Problem that I couldn't combine the values.
>
> The Result of my script looks like:
>
> => {"I OFF"=>["34"], "E OFF"=>["92", "94"], "E ON"=>["7f"],
>     "I ON"=>["d9", "cf"]}
>

Why are the elements in the arrays not numbers?  It looks like you rather
want to work with numbers (Fixnum) here.

I get always a nil when I want combine each value from one Array with
> the other values from the other Arrays. I use
>
>  data.first.product(*data[1..-1]).map(&:join)
>
> Can u say what the problem is now?
>

Can you show us what's in data?  Please make sure to present complete
examples, otherwise it's difficult to come up with answers - and to follow
the discussion as well.


> And if its possible can you explain how I can only combine I with E
> values.
> It doesnt make sense if I combine "I ON" with "I OFF" or "E ON" with "E
> OFF".
>

Well, just select e.g.

irb(main):001:0> h = {"I OFF"=>["34"], "E OFF"=>["92", "94"], "E
ON"=>["7f"], "I ON"=>["d9", "cf"]}
=> {"I OFF"=>["34"], "E OFF"=>["92", "94"], "E ON"=>["7f"], "I ON"=>["d9",
"cf"]}
irb(main):002:0> h.select {|k,| /^I/ =~ k}
=> {"I OFF"=>["34"], "I ON"=>["d9", "cf"]}
irb(main):003:0> h.select {|k,| /^E/ =~ k}
=> {"E OFF"=>["92", "94"], "E ON"=>["7f"]}

Kind regards

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/