4I505 - CPA/Project/src/Ruby/reading.rb
def read_points(points_file)
  points = []

  File.open "../../samples/" << points_file do |file|
    file.each_line do |line|
      coordinates = line.split(' ').map { |x| x.to_f }
      points << Geometry::Point.new(coordinates[0], coordinates[1])
    end
  end
  points
end
# Read all points from the file given in parameter. Stock in array.
Read all points from the file given in parameter. Stock in array.
Read all points from the file given in parameter . Stock in array .
def read_points(points_file)
  points = []
  File.open "../../samples/" << points_file do |file|
    file.each_line do |line|
      coordinates = line.split(' ').map { |x| x.to_f }
      points << Geometry::Point.new(coordinates[0], coordinates[1])
    end
  end
  points
end
def read_points ( points_file ) points = [ ] File . open "../../samples/" << points_file do | file | file . each_line do | line | coordinates = line . split ( ' ' ) . map { | x | x . to_f } points << Geometry :: Point . new ( coordinates [ 0 ] , coordinates [ 1 ] ) end end points end
Read all points from the file given in parameter.
Read all points from the file given in parameter .
points_file