Class: StreamStat

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/stream_stat.rb,
lib/stream_stat/v.rb,
lib/stream_stat/version.rb

Overview

StreamStat: Aggregate large data statictics with streaming.

Defined Under Namespace

Classes: V

Constant Summary collapse

VERSION =
'0.1.1'

Instance Method Summary collapse

Constructor Details

#initialize(enum) ⇒ StreamStat

Returns a new instance of StreamStat.



9
10
11
# File 'lib/stream_stat.rb', line 9

def initialize(enum)
  @enum = enum
end

Instance Method Details

#eachObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/stream_stat.rb', line 13

def each
  ys = Enumerator.new do |y|
    @enum.inject(V.new) do |v1, item|
      v2 = v1.next item
      y << v2
      v2
    end
  end
  ys.each { |stat| yield stat } if block_given?
  ys
end