class Bowling::Game

Attributes

frames[RW]

Public Class Methods

new( data = nil ) click to toggle source
# File lib/bowling/game.rb, line 6
def initialize( data = nil )
  @frames = Array.new( 10 ){ |i| Bowling::Frame.new i, self }
  load data if data
end

Public Instance Methods

load( data ) click to toggle source
# File lib/bowling/game.rb, line 12
def load( data )
  raise ArgumentError.new '#load needs array' unless data.instance_of? Array
  data.each_with_index{ |frame, i| @frames[i].load frame }
end
score() click to toggle source
# File lib/bowling/game.rb, line 18
def score
  frames.inject( 0 ){ |total, frame| total + frame.score }
end