<commit_before>class Bowling
  NUM_OF_FRAMES = 10
  attr_accessor :rolls

  def initialize
    @current_roll_index = 0
  end

  def score
    sum = 0

    game_rolls.each do
      if strike?
        sum += 10 + @rolls[@current_roll_index + 1].to_i + @rolls[@current_roll_index + 2].to_i
        @current_roll_index += 1
      elsif @rolls[@current_roll_index].to_i + @rolls[@current_roll_index + 1].to_i == 10
        sum += 10 + @rolls[@current_roll_index + 2].to_i
        @current_roll_index += 2
      else
        sum += @rolls[@current_roll_index].to_i + @rolls[@current_roll_index + 1].to_i
        @current_roll_index += 2
      end
    end
    sum
  end

private
  def strike?
    @rolls[@current_roll_index] == 10
  end

  def game_rolls
    @rolls.take(NUM_OF_FRAMES)
  end

end<commit_msg>more refactoring<commit_after>class Bowling
  NUM_OF_FRAMES = 10
  MAX_FRAME_POINTS = 10
  attr_accessor :rolls

  def initialize
    @current_roll_index = 0
  end

  def score
    sum = 0

    number_of_rolls.times do
      if strike?
        sum += MAX_FRAME_POINTS + @rolls[@current_roll_index + 1].to_i + @rolls[@current_roll_index + 2].to_i
        @current_roll_index += 1
      elsif spare?
        sum += MAX_FRAME_POINTS + @rolls[@current_roll_index + 2].to_i
        @current_roll_index += 2
      else
        sum += @rolls[@current_roll_index].to_i + @rolls[@current_roll_index + 1].to_i
        @current_roll_index += 2
      end
    end
    sum
  end

private
  def strike?
    @rolls[@current_roll_index] == MAX_FRAME_POINTS
  end

  def spare?
    @rolls[@current_roll_index].to_i + @rolls[@current_roll_index + 1].to_i == MAX_FRAME_POINTS
  end

  def number_of_rolls
    @rolls.take(NUM_OF_FRAMES).size
  end

end
{'fraction_non_alphanumeric': 0.09815242494226328, 'fraction_numerical': 0.019630484988452657, 'mean_word_length': 2.8425720620842574, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3985015', 'n_tokens_mistral': 684, 'n_tokens_neox': 643, 'n_words': 126}