Class: Contrek::Reducers::LinearReducer

Inherits:
Reducer
  • Object
show all
Defined in:
lib/contrek/reducers/linear_reducer.rb

Instance Method Summary collapse

Methods inherited from Reducer

#initialize

Constructor Details

This class inherits a constructor from Contrek::Reducers::Reducer

Instance Method Details

#reduce!Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/contrek/reducers/linear_reducer.rb', line 4

def reduce!
  start_p = @points[0]
  end_p = @points[1]
  dir = seq_dir(start_p, end_p)
  @points[2..].map.with_index do |point, i|
    if (act_seq = seq_dir(end_p, point)) == dir
      @points.delete_at(@points.index(end_p))
    else
      dir = act_seq
    end
    end_p = point
  end
end