Class: Knossos::Renderer::Text
- Inherits:
-
Object
- Object
- Knossos::Renderer::Text
- Defined in:
- lib/knossos/renderer/text.rb
Instance Method Summary collapse
-
#initialize ⇒ Text
constructor
A new instance of Text.
- #render(grid:, distances: nil) ⇒ Object
Constructor Details
#initialize ⇒ Text
Returns a new instance of Text.
4 5 6 |
# File 'lib/knossos/renderer/text.rb', line 4 def initialize # nothing to do end |
Instance Method Details
#render(grid:, distances: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/knossos/renderer/text.rb', line 8 def render(grid:, distances: nil) output = "+" + "---+" * grid.columns + "\n" grid.each_row do |row| body = "|" bottom = "+" row.each do |cell| east = grid.east(cell) east_border = cell.linked?(east) ? " " : "|" south = grid.south(cell) south_border = cell.linked?(south) ? " " : "---" body << decorate(cell, distances) << east_border bottom << south_border << "+" end output << body << "\n" output << bottom << "\n" end output end |