Class: BowlingScore::ScoreCalculator

Inherits:
Object
  • Object
show all
Defined in:
lib/bowling_score/score_calculator.rb

Overview

Score Calculator - taking an array or string of scores (integers)

and calculate with strike and spare rewarding

Instance Method Summary collapse

Constructor Details

#initialize(scores) ⇒ ScoreCalculator

Returns a new instance of ScoreCalculator.



5
6
7
8
# File 'lib/bowling_score/score_calculator.rb', line 5

def initialize(scores)
  @scores = scores.is_a?(String) ? scores.split(',') : scores
  @scores = @scores.map(&:to_i)
end

Instance Method Details

#calculateObject



10
11
12
13
# File 'lib/bowling_score/score_calculator.rb', line 10

def calculate
  @current_frame = 0
  _calculate_from_frame(0)
end