Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/rails_dictionary/array_core_ext.rb
Instance Method Summary collapse
-
#extract_to_hash(keys_array) ⇒ Object
Return a hash by compare two arrays.
Instance Method Details
#extract_to_hash(keys_array) ⇒ Object
Return a hash by compare two arrays
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/rails_dictionary/array_core_ext.rb', line 3 def extract_to_hash(keys_array) ret_hash={} keys_array.each {|ky| ret_hash[ky.to_sym]=[]} self.each do |sf| keys_array.each do |ky| ret_hash[ky.to_sym] << sf.sub("#{ky}_","") if sf =~ Regexp.new("^#{ky}_") end end ret_hash.reject { |k,v| v.blank? } end |