Class: Xail::SampleFilter

Inherits:
AbstractFilter show all
Defined in:
lib/xail/filter.rb

Overview

Stream Mutators

Instance Method Summary collapse

Methods inherited from AbstractFilter

#filterName

Constructor Details

#initialize(params) ⇒ SampleFilter

Returns a new instance of SampleFilter.



219
220
221
222
# File 'lib/xail/filter.rb', line 219

def initialize(params)
  @rate = params.to_i
  @count = 0
end

Instance Method Details

#streamLine(line) ⇒ Object



224
225
226
227
228
229
230
231
232
233
# File 'lib/xail/filter.rb', line 224

def streamLine(line)
  res = if @count % @rate == 0
    line
  else
    ""
  end

  @count += 1
  res
end