lib/mazes/cartesian/space.rb
# Public: Represent the Space as text in 2-Dimensional Cartesian geometry.
#
# This is very simple, as paper and computer screens are ALSO 2-D Cartesian.
#
# Returns a String representation of the Space.
Represent the Space as text in 2-Dimensional Cartesian geometry.
This is very simple, as paper and computer screens are ALSO 2-D Cartesian.

Returns a String representation of the Space.
Represent the Space as text in 2 - Dimensional Cartesian geometry . This is very simple as paper and computer screens are ALSO 2 - D Cartesian . Returns a String representation of the Space .
def to_s
			ret =  "\u2554#{("\u2550" * 3 + "\u2566") * @x}\b\u2557\n"
			s_width = 4 * (@x + 1)
			each_row do |row|
				mid = "\u2551"
				bot = "\u2560"
				row.each do |cell|
					cell ||= Cell.new x: -1, y: -1
					body = " #{contents_of cell: cell} "
					bound_r = (cell.linked?(cell: cell.right) ? " " : "\u2551")
					bound_d = (cell.linked?(cell: cell.down)  ? " " : "\u2550") * 3
					mid << body << bound_r
					bot << bound_d << "\u256C"
				end
				ret << mid << "\n"
				ret << bot << "\b\u2563\n"
			end
			ret = ret[0, ret.length - s_width]
			ret << "\u255A#{("\u2550" * 3 + "\u2569") * @x}\u0008\u255D\n"
			ret
		end
def to_s ret = "\u2554#{("\u2550" * 3 + "\u2566") * @x}\b\u2557\n" s_width = 4 * ( @x + 1 ) each_row do | row | mid = "\u2551" bot = "\u2560" row . each do | cell | cell ||= Cell . new x : - 1 , y : - 1 body = " #{contents_of cell: cell} " bound_r = ( cell . linked? ( cell : cell . right ) ? " " : "\u2551" ) bound_d = ( cell . linked? ( cell : cell . down ) ? " " : "\u2550" ) * 3 mid << body << bound_r bot << bound_d << "\u256C" end ret << mid << "\n" ret << bot << "\b\u2563\n" end ret = ret [ 0 , ret . length - s_width ] ret << "\u255A#{("\u2550" * 3 + "\u2569") * @x}\u0008\u255D\n" ret end
Public: Represent the Space as text in 2-Dimensional Cartesian geometry.
Public : Represent the Space as text in 2 - Dimensional Cartesian geometry .
# Instead of doing annoying math to swap the last junction for a corner, # just backspace and print a corner.