Pergunta

>> description

=> [" name=\"margin-top\" content=\"1\" />\r\n", " name=\"oreintation\" content=\"horizontal\" />\r\n", " name=\"paper-height\" content=\"6\" />\r\n", " name=\"paper-width\" content=\"5\" />\r\n", " name=\"margin-left\" content=\"3\" />\r\n"]

description is of type array

I need key as margin-top value 1.
I need key as oreintation value oreintation and so on, how to get this done?

Foi útil?

Solução

Use

result = {}
description.each{|val|
 result[val.split("\"")[1]] = val.split("\"")[3]
}
result # contains expected hash
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top