Class: Board
- Inherits:
-
Object
- Object
- Board
- Defined in:
- lib/board.rb
Instance Attribute Summary collapse
-
#cols ⇒ Object
readonly
Returns the value of attribute cols.
-
#matriz ⇒ Object
readonly
Returns the value of attribute matriz.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #getMatriz ⇒ Object
-
#initialize(cols, rows) ⇒ Board
constructor
A new instance of Board.
- #printBoard ⇒ Object
- #setPoint(x, sym) ⇒ Object
Constructor Details
#initialize(cols, rows) ⇒ Board
Returns a new instance of Board.
6 7 8 9 10 11 |
# File 'lib/board.rb', line 6 def initialize(cols, rows) @cols = cols @rows = rows setMatriz() printBoard() end |
Instance Attribute Details
#cols ⇒ Object (readonly)
Returns the value of attribute cols.
5 6 7 |
# File 'lib/board.rb', line 5 def cols @cols end |
#matriz ⇒ Object (readonly)
Returns the value of attribute matriz.
5 6 7 |
# File 'lib/board.rb', line 5 def matriz @matriz end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
5 6 7 |
# File 'lib/board.rb', line 5 def rows @rows end |
Instance Method Details
#getMatriz ⇒ Object
63 64 65 |
# File 'lib/board.rb', line 63 def getMatriz return $matriz end |
#printBoard ⇒ Object
39 40 41 42 43 |
# File 'lib/board.rb', line 39 def printBoard printRows() printMatriz() puts '' end |
#setPoint(x, sym) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/board.rb', line 45 def setPoint(x, sym) point = 0 if x < @rows point = @cols+1 x -= 1 while $matriz[point][x] != '|' do point = point - 1 end $matriz[point][x] = sym system 'clear' or system 'cls' printBoard() else puts "Exception: Number of selected row too big" raise BigNumber end return point end |