Method: PerfectShape::MultiPoint.normalize_point_array

Defined in:
lib/perfect_shape/multi_point.rb

.normalize_point_array(the_points) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/perfect_shape/multi_point.rb', line 28

def normalize_point_array(the_points)
  if the_points.all? {|the_point| the_point.is_a?(Array)}
    the_points
  else
    the_points = the_points.flatten
    xs = the_points.each_with_index.select {|n, i| i.even?}.map(&:first)
    ys = the_points.each_with_index.select {|n, i| i.odd?}.map(&:first)
    xs.zip(ys)
  end
end