class Digiproc::Strategies::CustomCompandingStrategy

A class which allows a custom companding strategy to be used via a lambda function inputted into the initilizer.

Attributes

eqn[RW]
inverse[RW]

Public Class Methods

new(eqn, inverse) click to toggle source

initialize wiht a companding equation (via a proc or lambda) as well as the inverse equation

# File lib/strategies/companding/custom_companding_strategy.rb, line 10
def initialize(eqn, inverse)
    @eqn, @inverse = eqn, inverse
end

Public Instance Methods

compress(data) click to toggle source

use the compression companding lambda (or proc) to compress an array of numerics

# File lib/strategies/companding/custom_companding_strategy.rb, line 20
def compress(data)
    self.process(data, eqn)
end
expand(data) click to toggle source

Use the inverse labda (or proc) to decompress an array of numerics

# File lib/strategies/companding/custom_companding_strategy.rb, line 25
def expand(data)
    self.process(data, inverse)
end
process(data, fn) click to toggle source

maps an array (first argument) with a lambda (second argument)

# File lib/strategies/companding/custom_companding_strategy.rb, line 15
def process(data, fn)
    data.map{ |n| fn.call(n) }
end