class BattleBoats::Cell
Attributes
occupant[RW]
Public Class Methods
new()
click to toggle source
# File lib/battle_boats/cell.rb, line 7 def initialize @hit = false @occupant = BattleBoats::NullShip.new end
Public Instance Methods
hit?()
click to toggle source
# File lib/battle_boats/cell.rb, line 12 def hit? @hit end
occupied?()
click to toggle source
# File lib/battle_boats/cell.rb, line 32 def occupied? !occupant.empty? end
status_report()
click to toggle source
# File lib/battle_boats/cell.rb, line 23 def status_report occupant_name = occupant.name if occupant.sunk? "You sunk my #{occupant_name}!" elsif hit? "You hit my #{occupant_name}!" end end
strike()
click to toggle source
# File lib/battle_boats/cell.rb, line 16 def strike if !hit? occupant.hit @hit = true end end