Class: Bmg::Summarizer::Bucketize

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

Overview

Bucketizer summarizer.

Example:

# direct ruby usage
Bmg::Summarizer.bucketize(:qty, :size => 2).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, #happens, #initialize, 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

This class inherits a constructor from Bmg::Summarizer

Instance Method Details

#_happens(memo, val) ⇒ Object

Concatenates current memo with val.to_s



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

def _happens(memo, val)
  memo.first << val
  memo
end

#default_optionsObject

Sets default options.



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

def default_options
  { :size => 10 }
end

#finalize(memo) ⇒ Object

Finalizes computation



30
31
32
33
34
# File 'lib/bmg/summarizer/bucketize.rb', line 30

def finalize(memo)
  buckets = compute_buckets(memo.first, options[:size])
  buckets = touching_buckets(buckets) if options[:boundaries] == :touching
  buckets
end

#leastObject

Returns least value (defaults to “”)



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

def least()
  [[], []]
end