Class: Cell

Inherits:
Object
  • Object
show all
Includes:
State
Defined in:
lib/cell.rb

Overview

class Cell describes cell state

Constant Summary

Constants included from State

State::BROKEN, State::EMPTY, State::MISSED, State::SHIP

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(col, row, st = EMPTY) ⇒ Cell

Returns a new instance of Cell.



13
14
15
16
17
# File 'lib/cell.rb', line 13

def initialize(col, row, st = EMPTY)
  @state = st
  @col = col
  @row = row
end

Instance Attribute Details

#stateObject

Returns the value of attribute state.



12
13
14
# File 'lib/cell.rb', line 12

def state
  @state
end

Instance Method Details

#to_sObject



27
28
29
# File 'lib/cell.rb', line 27

def to_s
  "Cell [#{@col}:#{@row}] State = #{@state}"
end