ruby on rails - Array to key value pair (Hash) -


>> 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 of type array

i need key margin-top value 1.
need key oreintation value oreintation , on, how done?

use

result = {} description.each{|val|  result[val.split("\"")[1]] = val.split("\"")[3] } result # contains expected hash 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -