Class: Hash
- Defined in:
- lib/plist4r/mixin/ruby_stdlib.rb
Direct Known Subclasses
Instance Methods
Instance Method Details
- (Object) merge_array_of_hashes_of_arrays(array_of_hashes_of_arrays)
Merge together an array of complex hash structures
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/plist4r/mixin/ruby_stdlib.rb', line 90 def merge_array_of_hashes_of_arrays array_of_hashes_of_arrays a = array_of_hashes_of_arrays raise "not an array_of_hashes_of_arrays" unless a.is_a? Array if a[0].is_a? Hash h = self.deep_clone a.each_index do |i| raise "not an array_of_hashes_of_arrays" unless a[i].is_a? Hash a[i].each do |k,v| raise "not an array_of_hashes_of_arrays" unless v.is_a? Array h[k] = [h[k]].flatten.compact + v end end else raise "not an array_of_hashes_of_arrays" end h end |
- (Object) merge_array_of_hashes_of_arrays!(array_of_hashes_of_arrays)
109 110 111 112 113 |
# File 'lib/plist4r/mixin/ruby_stdlib.rb', line 109 def merge_array_of_hashes_of_arrays! array_of_hashes_of_arrays h = merge_array_of_hashes_of_arrays array_of_hashes_of_arrays self.replace h self end |