I have a hash like this:
test
=> {"QTC-1 test"=>"pass", "QTC-2 test"=>"fail"}
I want to take each key in the hash and remove all characters after the numbers, example:
"QTC-1 test" should equal "QTC-1"
I am close to the solution but not fully there:
str = test.keys[0]
=> "QTC-1 test"
new = str.slice(0..(str.index(/\d/)))
=> "QTC-1"
But need some help doing that with the hash key(s).
Bonus
Changing the values to corresponding number values:
So if value = pass then change it to 1 or if value = fail then change it to 2.
Bonus possible answer:
scenarios.each_pair { |k, v|
case v
when 'pass'
scenarios[k] = 1
when 'fail'
scenarios[k] = 2
when 'block'
scenarios[k] = 3
else
scenarios[k] = 4
end
}