Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/jrubyfx/utils.rb
Overview
Standard ruby Hash class extensions
Instance Method Summary collapse
-
#flat_tree_inject(klass = Array, &block) ⇒ Object
call-seq: flat_tree_inject() {|results, key, value| block} => array flat_tree_inject(Hash) {|results, key, value| block} => hash.
Instance Method Details
#flat_tree_inject(klass = Array, &block) ⇒ Object
call-seq:
flat_tree_inject() {|results, key, value| block} => array
flat_tree_inject(Hash) {|results, key, value| block} => hash
Execute given block against all nodes in the hash tree, returning ‘results`. Similar to Hash#each except goes into all sub-Hashes
30 31 32 33 34 35 36 37 |
# File 'lib/jrubyfx/utils.rb', line 30 def flat_tree_inject(klass=Array,&block) self.inject(klass.new) do |lres, pair| if pair[1].is_a? Hash pair[1] = pair[1].flat_tree_inject(klass, &block) end block.call(lres, *pair) end end |