Class: Hellgrid::Views::Console
- Inherits:
-
Object
- Object
- Hellgrid::Views::Console
- Defined in:
- lib/hellgrid/views/console.rb
Instance Attribute Summary collapse
-
#matrix ⇒ Object
readonly
Returns the value of attribute matrix.
Instance Method Summary collapse
-
#initialize(matrix) ⇒ Console
constructor
A new instance of Console.
- #render ⇒ Object
- #render_as_string ⇒ Object
Constructor Details
#initialize(matrix) ⇒ Console
Returns a new instance of Console.
8 9 10 |
# File 'lib/hellgrid/views/console.rb', line 8 def initialize(matrix) @matrix = matrix end |
Instance Attribute Details
#matrix ⇒ Object (readonly)
Returns the value of attribute matrix.
6 7 8 |
# File 'lib/hellgrid/views/console.rb', line 6 def matrix @matrix end |
Instance Method Details
#render ⇒ Object
12 13 14 |
# File 'lib/hellgrid/views/console.rb', line 12 def render puts render_as_string end |
#render_as_string ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/hellgrid/views/console.rb', line 16 def render_as_string string = [] string << row_as_string(matrix[0]) string << column_widths.map { |width| '-' * width }.join('+') matrix[1..matrix.size].each do |row| string << row_as_string(row) end "#{string.join("\n")}\n" end |