Class: Noyes::DeltaEncoder

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_impl/compression.rb

Instance Method Summary collapse

Constructor Details

#initialize(dimensions = 13) ⇒ DeltaEncoder

Returns a new instance of DeltaEncoder.


28
29
30
31
# File 'lib/ruby_impl/compression.rb', line 28

def initialize dimensions=13
  @dimensions = dimensions
  @delta = Array.new dimensions, 0.0
end

Instance Method Details

#<<(data) ⇒ Object


33
34
35
36
37
38
39
40
41
# File 'lib/ruby_impl/compression.rb', line 33

def << data
  data.each_slice(@dimensions).map do |array|
    array.each_with_index.map do |element, index|
      current_delta = @delta[index]
      @delta[index] = element
      element - current_delta
    end
  end
end