ruby - Filter keys of hashes -


i have these hashes in hashes variable:

{:priority=>100, :iso_code=>"jpy", :name=>"japanese yen", :symbol=>"¥", :alternate_symbols=>["円", "圓"], :subunit=>"sen", :subunit_to_unit=>100, :symbol_first=>true, :html_entity=>"¥", :decimal_mark=>".", :thousands_separator=>",", :iso_numeric=>""} {:priority=>100, :iso_code=>"zwd", :name=>"zimbabwean dollar", :symbol=>"$", :alternate_symbols=>["z$"], :subunit=>"cent", :subunit_to_unit=>100, :symbol_first=>true, :html_entity=>"$", :decimal_mark=>".", :thousands_separator=>",", :iso_numeric=>"716"} {:priority=>100, :iso_code=>"zwl", :name=>"zimbabwean dollar", :symbol=>"$", :alternate_symbols=>["z$"], :subunit=>"cent", :subunit_to_unit=>100, :symbol_first=>true, :html_entity=>"$", :decimal_mark=>".", :thousands_separator=>",", :iso_numeric=>"932"} {:priority=>100, :iso_code=>"zwn", :name=>"zimbabwean dollar", :symbol=>"$", :alternate_symbols=>["z$"], :subunit=>"cent", :subunit_to_unit=>100, :symbol_first=>true, :html_entity=>"$", :decimal_mark=>".", :thousands_separator=>",", :iso_numeric=>"942"} {:priority=>100, :iso_code=>"zwr", :name=>"zimbabwean dollar", :symbol=>"$", :alternate_symbols=>["z$"], :subunit=>"cent", :subunit_to_unit=>100, :symbol_first=>true, :html_entity=>"$", :decimal_mark=>".", :thousands_separator=>",", :iso_numeric=>"935"} 

i want fill/update hashes variable 3 keys:

:iso_code :name :symbol 

how can it?

{:priority=>100, :iso_code=>"jpy", :name=>"japanese yen", :symbol=>"¥", :alternate_symbols=>["円", "圓"], :subunit=>"sen", :subunit_to_unit=>100, :symbol_first=>true, :html_entity=>"¥", :decimal_mark=>".", :thousands_separator=>",", :iso_numeric=>""} .select{|k, _| [:iso_code, :name, :symbol].include?(k)} # => {:iso_code=>"jpy", :name=>"japanese yen", :symbol=>"¥"} 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -