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
6 7 8 |
# File 'lib/hellgrid/views/console.rb', line 6 def initialize(matrix) @matrix = matrix end |
Instance Attribute Details
#matrix ⇒ Object (readonly)
Returns the value of attribute matrix.
4 5 6 |
# File 'lib/hellgrid/views/console.rb', line 4 def matrix @matrix end |
Instance Method Details
#render ⇒ Object
10 11 12 |
# File 'lib/hellgrid/views/console.rb', line 10 def render puts render_as_string end |
#render_as_string ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hellgrid/views/console.rb', line 14 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 |