Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/seqtrimnext/utils/hash_stats.rb

Instance Method Summary collapse

Instance Method Details

#add_stats(h_stats) ⇒ Object

three levels: STATS->plugin_name->Property->count



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/seqtrimnext/utils/hash_stats.rb', line 9

def add_stats(h_stats)
  h=self

  h_stats.each do |plugin_hash,add_stats|
    h[plugin_hash]={} if h[plugin_hash].nil?  
    
    add_stats.each do |property,hash_value|
      h[plugin_hash][property]={} if h[plugin_hash][property].nil? 
    
      # values need to be in string format because of later loading from json file
      hash_value.each do |value, count|
        h[plugin_hash][property][value.to_s]=(h[plugin_hash][property][value.to_s]||0) + count
      end
    end
  end

end