Class: Bmg::Summarizer::Multiple

Inherits:
Bmg::Summarizer show all
Defined in:
lib/bmg/summarizer/multiple.rb

Overview

A summarizer that collects multiple summarization as a wrapped tuple.

Example:

# direct ruby usage
Bmg::Summarizer.multiple(x: ..., y: ...).summarize(...)

Instance Attribute Summary

Attributes inherited from Bmg::Summarizer

#functor, #options

Instance Method Summary collapse

Methods inherited from Bmg::Summarizer

avg, bucketize, by_proc, collect, concat, count, distinct, distinct_count, first, last, max, median, median_cont, median_disc, min, multiple, percentile, percentile_cont, percentile_disc, stddev, sum, summarization, #summarize, #to_summarizer_name, value_by, variance

Constructor Details

#initialize(defs) ⇒ Multiple

Returns a new instance of Multiple.



14
15
16
# File 'lib/bmg/summarizer/multiple.rb', line 14

def initialize(defs)
  @summarization = Summarizer.summarization(defs)
end

Instance Method Details

#finalize(memo) ⇒ Object



32
33
34
35
36
# File 'lib/bmg/summarizer/multiple.rb', line 32

def finalize(memo)
  @summarization.each_pair.each_with_object({}){|(k,v),memo2|
    memo2[k] = v.finalize(memo[k])
  }
end

#happens(memo, val) ⇒ Object

Adds val to the memo array



26
27
28
29
30
# File 'lib/bmg/summarizer/multiple.rb', line 26

def happens(memo, val)
  @summarization.each_pair.each_with_object({}){|(k,v),memo2|
    memo2[k] = v.happens(memo[k], val)
  }
end

#leastObject

Returns [] as least value.



19
20
21
22
23
# File 'lib/bmg/summarizer/multiple.rb', line 19

def least()
  @summarization.each_pair.each_with_object({}){|(k,v),memo|
    memo[k] = v.least
  }
end