ruby on rails - How to create hash out of specific words in text? -
i have file following content:
class rename < activerecord::migration def change rename_table :users, :vendors rename_table :places, :venues #there loads of similar lines end end
and need create hash following structure:
{ "users" => "vendors", "places" => "venues" }
how can achieve this?
i can fetch needed words using regular expression method scan /rename_table.:(\s+),\s:(\s+)/
, returns
[["users", "vendors"], ["places", "venues"]]
[["users", "vendors"], ["places", "venues"]].to_h => {"users"=>"vendors", "places"=>"venues"}
Comments
Post a Comment