class BoatList
Public Class Methods
new(boat_list)
click to toggle source
# File lib/boat_list.rb, line 3 def initialize(boat_list) @boat_list = boat_list end
Public Instance Methods
all_boats_sunk?()
click to toggle source
# File lib/boat_list.rb, line 35 def all_boats_sunk? @boat_list.all? {|boat| boat.sunk?} end
any_boat_hit?(target_grid_point)
click to toggle source
# File lib/boat_list.rb, line 7 def any_boat_hit?(target_grid_point) @boat_list.each do |boat| return true if boat.any_point_matched?(target_grid_point) end false end
boat_sunk?(target_grid_point)
click to toggle source
# File lib/boat_list.rb, line 22 def boat_sunk?(target_grid_point) @boat_list.each do |boat| if boat.any_point_matched?(target_grid_point) return true if boat.sunk? end end false end
count_boats_not_sunk()
click to toggle source
# File lib/boat_list.rb, line 31 def count_boats_not_sunk @boat_list.length - @boat_list.count {|boat| boat.sunk?} end
record_boat_hit(target_grid_point)
click to toggle source
# File lib/boat_list.rb, line 14 def record_boat_hit(target_grid_point) @boat_list.each do |boat| if boat.any_point_matched?(target_grid_point) boat.record_hit(target_grid_point) end end end