Class: Radio::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/radio/filter.rb,
lib/radio/filters/iq.rb,
lib/radio/filters/agc.rb,
lib/radio/filters/fir.rb

Overview

This generic Filter class will optimize by replacing its #call with an optimized version from a module. The type of data and initializer options determine the module to load.

Defined Under Namespace

Modules: Agc, Fir, InterpolateFir, Iq, Mix, MixDecimateFir, MixFir, MixInterpolateFir, SetupFir

Constant Summary collapse

TYPES =
%w{
  iq mix interpolate decimate fir agc
}.collect(&:to_sym).freeze

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Filter

Returns a new instance of Filter.



27
28
29
30
31
32
33
34
35
# File 'lib/radio/filter.rb', line 27

def initialize options
  @options = options
  @mod_name = ''
  TYPES.each do |type|
    @mod_name += type.to_s.capitalize if @options[type]
  end
  extend eval @mod_name
  setup
end

Instance Method Details

#call(data, &block) ⇒ Object



37
38
39
40
# File 'lib/radio/filter.rb', line 37

def call data, &block
  extend_by_data_type data
  call data, &block
end

#call!(data, &block) ⇒ Object



42
43
44
45
# File 'lib/radio/filter.rb', line 42

def call! data, &block
  extend_by_data_type data
  call! data, &block
end

#setupObject



47
48
49
# File 'lib/radio/filter.rb', line 47

def setup
  # noop
end