Class: Bmg::Summarizer::ByProc

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

Overview

Generic summarizer that takes a Proc àla each_with_object.

Example:

# direct ruby usage
Bmg::Summarizer.by_proc{|t,memo| ... }.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(least, by_proc) ⇒ ByProc

Returns a new instance of ByProc.



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

def initialize(least, by_proc)
  @least = least
  @by_proc = by_proc
end

Instance Method Details

#finalize(memo) ⇒ Object



28
29
30
# File 'lib/bmg/summarizer/by_proc.rb', line 28

def finalize(memo)
  memo
end

#happens(memo, val) ⇒ Object

Adds val to the memo array



24
25
26
# File 'lib/bmg/summarizer/by_proc.rb', line 24

def happens(memo, val)
  @by_proc.call(val, memo)
end

#leastObject

Returns [] as least value.



19
20
21
# File 'lib/bmg/summarizer/by_proc.rb', line 19

def least
  @least
end