Class: LifeVisualizer
- Inherits:
-
Object
- Object
- LifeVisualizer
- Defined in:
- lib/life_game_viewer/model/life_visualizer.rb
Overview
Manages the string display of a life model.
Instance Method Summary collapse
-
#to_display_string(model) ⇒ Object
Returns a string representation of a LifeModel.
Instance Method Details
#to_display_string(model) ⇒ Object
Returns a string representation of a LifeModel.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/life_game_viewer/model/life_visualizer.rb', line 6 def to_display_string(model) output = '' (0...model.row_count).each do |x| (0...model.column_count).each do |y| alive_as_string = model.alive?(x, y) ? '*' : '-' output << alive_as_string end output << "\n" end output end |