Commit 6045e984de48273718907755930c386b89a00551

Authored by Tres Trantham
1 parent dc20dee6

Add ability to carry forward values from previous interval

Showing 1 changed file with 5 additions and 1 deletions   Show diff stats
lib/groupdate/magic.rb
... ... @@ -226,8 +226,12 @@ module Groupdate
226 226 lambda{|k| k }
227 227 end
228 228  
  229 + value = nil
  230 +
229 231 Hash[series.map do |k|
230   - [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]
  232 + value = count[k] || (@options[:carry_forward] ? value : false) || default_value
  233 +
  234 + [multiple_groups ? k[0...@group_index] + [key_format.call(k[@group_index])] + k[(@group_index + 1)..-1] : key_format.call(k), value]
231 235 end]
232 236 end
233 237  
... ...