Class: KnightsTour::StringResult

Inherits:
Object
  • Object
show all
Defined in:
lib/knights_tour.rb

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ StringResult

Returns a new instance of StringResult.



139
140
141
142
143
144
145
# File 'lib/knights_tour.rb', line 139

def initialize(result)
  if result.is_a?(Knight)
    @result = board_to_s(result.board, result.steps_taken)
  else
    @result = "No solution found."
  end
end

Instance Method Details

#to_sObject



147
148
149
# File 'lib/knights_tour.rb', line 147

def to_s
  @result
end