Method: BBLib::HashPathProcs.avg

Defined in:
lib/hash_path/processors.rb

.avg(child, *args, class_based: true) ⇒ Object



206
207
208
209
# File 'lib/hash_path/processors.rb', line 206

def self.avg(child, *args, class_based: true)
  nums = child.value.to_s.extract_numbers
  child.replace_with(nums.inject { |s, x| s + x }.to_f / nums.size.to_f)
end