将两个字符串转换为ruby哈希?

将两个字符串转换为ruby哈希?,ruby,hash,nokogiri,Ruby,Hash,Nokogiri,现在,我有以下几点: <% @headlines.css('a').each do | headline | %> <%= headline.text %> <% end %> <% @top_stories.css('a').each do | top_story | %> <%= top_story.text %> <% end %> 我想把这两个字符串转换成ruby哈希。大概是这样的: {:headli

现在,我有以下几点:

<% @headlines.css('a').each do | headline | %>
   <%= headline.text %>
<% end %>

<% @top_stories.css('a').each do | top_story | %>
   <%= top_story.text %>
<% end %>
我想把这两个字符串转换成ruby哈希。大概是这样的:

{:headlines => ['Kobe ahead of schedule'], etc etc, :top_stories: ['Ex-Lebron pest Stevenson pinning to join Heat', etc etc] } 
如何做到这一点?

,={},'
<%= hash_res %>, <%= headline %> = {}, ''
<% @headlines.css('a').each do | headline | %>
    <%= headline %> << <%= headline.text %>
<% end %>
<%= head_res[:headlines] %> = headline

# Do the same thing for the below
<% @top_stories.css('a').each do | top_story | %>
    <%= top_story.text %>
<% end %>
<%= hash_res %>, <%= headline %> = {}, ''
<% @headlines.css('a').each do | headline | %>
    <%= headline %> << <%= headline.text %>
<% end %>
<%= head_res[:headlines] %> = headline

# Do the same thing for the below
<% @top_stories.css('a').each do | top_story | %>
    <%= top_story.text %>
<% end %>