Class: Radio::Utils::FirPM

Inherits:
Object
  • Object
show all
Defined in:
lib/radio/utils/firpm.rb

Overview

Instances of FirPM will act as the result array. The result is lazily generated just-in-time for the first use. This allows for CONSTANT=FirPM.new assignments without the huge penalty to application startup. It also let’s us normalize the options at initialization for use as a cache key. It is strongly recommended to use the caching mixin.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ FirPM

:type may be in [:bandpass, :differentiator, :hilbert] :maxiterations won’t raise error when negative



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/radio/utils/firpm.rb', line 66

def initialize options
  # normalized and frozen to be suitable for a hash key
  @options = {
    type: options[:type].to_sym,
    numtaps: options[:numtaps].to_i,
    bands: options[:bands].flatten.collect(&:to_f).freeze,
    desired: options[:desired].collect(&:to_f).freeze,
    weights: options[:weights].collect(&:to_f).freeze,
    griddensity: options[:griddensity] || 16,
    maxiterations: options[:maxiterations] || 40
  }.freeze
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *opts, &block) ⇒ Object



80
81
82
83
# File 'lib/radio/utils/firpm.rb', line 80

def method_missing name, *opts, &block
  firpm unless @h
  @h.send name, *opts, &block
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



78
79
80
# File 'lib/radio/utils/firpm.rb', line 78

def options
  @options
end