Class: PointsToLine
- Inherits:
-
Object
- Object
- PointsToLine
- Defined in:
- lib/ruby-doom.rb
Instance Method Summary collapse
-
#initialize(points, debug = false) ⇒ PointsToLine
constructor
A new instance of PointsToLine.
- #line ⇒ Object
- #lower_left ⇒ Object
Constructor Details
#initialize(points, debug = false) ⇒ PointsToLine
Returns a new instance of PointsToLine.
76 77 78 79 |
# File 'lib/ruby-doom.rb', line 76 def initialize(points, debug=false) @points = points @debug = debug end |
Instance Method Details
#line ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ruby-doom.rb', line 83 def line @f = Finder.new(@points, 5, @debug) found_so_far = [lower_left] current = @f.next(found_so_far[0], found_so_far) while found_so_far.size != @points.size - 1 found_so_far << current puts "Current = " + current.to_s + "; points so far: " + found_so_far.size.to_s unless !@debug begin current = @f.next(current, found_so_far) rescue puts "Couldn't find next point, so skipping back to the origin" unless !@debug break end end found_so_far << current end |