Commit 21208ef8241ad78ce54d59327227d70eab10e4a6
Exists in
cumulative_sum
Merge branch 'trestrantham-value-carry-forward' into trestrantham-master
Showing
1 changed file
with
5 additions
and
1 deletions
Show diff stats
lib/groupdate/magic.rb
... | ... | @@ -230,8 +230,12 @@ module Groupdate |
230 | 230 | lambda{|k| k } |
231 | 231 | end |
232 | 232 | |
233 | + value = nil | |
234 | + | |
233 | 235 | Hash[series.map do |k| |
234 | - [multiple_groups ? k[0...@group_index] + [key_format.call(k[@group_index])] + k[(@group_index + 1)..-1] : key_format.call(k), count[k] || default_value] | |
236 | + value = count[k] || (@options[:carry_forward] ? value : false) || default_value | |
237 | + | |
238 | + [multiple_groups ? k[0...@group_index] + [key_format.call(k[@group_index])] + k[(@group_index + 1)..-1] : key_format.call(k), value] | |
235 | 239 | end] |
236 | 240 | end |
237 | 241 | ... | ... |