Class: Bmg::Summarizer::Positional
- Inherits:
-
Bmg::Summarizer
- Object
- Bmg::Summarizer
- Bmg::Summarizer::Positional
- Defined in:
- lib/bmg/summarizer/positional.rb
Overview
See First and Last
Instance Attribute Summary collapse
-
#ordering ⇒ Object
readonly
Returns the value of attribute ordering.
Attributes inherited from Bmg::Summarizer
Instance Method Summary collapse
- #finalize(memo) ⇒ Object
- #happens(memo, tuple) ⇒ Object
-
#initialize(*args, &block) ⇒ Positional
constructor
A new instance of Positional.
- #least ⇒ Object
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(*args, &block) ⇒ Positional
Returns a new instance of Positional.
6 7 8 9 10 |
# File 'lib/bmg/summarizer/positional.rb', line 6 def initialize(*args, &block) super raise ArgumentError, "Missing order" unless [:order] @ordering = Ordering.new([:order]) end |
Instance Attribute Details
#ordering ⇒ Object (readonly)
Returns the value of attribute ordering.
11 12 13 |
# File 'lib/bmg/summarizer/positional.rb', line 11 def ordering @ordering end |
Instance Method Details
#finalize(memo) ⇒ Object
26 27 28 29 |
# File 'lib/bmg/summarizer/positional.rb', line 26 def finalize(memo) return nil if memo.nil? extract_value(memo) end |
#happens(memo, tuple) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/bmg/summarizer/positional.rb', line 17 def happens(memo, tuple) if memo.nil? tuple else c = ordering.call(memo, tuple) c <= 0 ? choose(memo, tuple) : choose(tuple, memo) end end |
#least ⇒ Object
13 14 15 |
# File 'lib/bmg/summarizer/positional.rb', line 13 def least nil end |