<commit_before>require File.expand_path('../../models/book', __FILE__)

module Kindle
  module Annotator
    module Models
      class Books
        BookNotFoundError = Class.new(StandardError)

        include Enumerable

        def initialize(collection)
          @collection = Array(collection)
        end

        def each(&block)
          books_collection.each(&block)
        end

        def find_by_id(id)
          self.select { |record| record.id == id }.first
        end
        alias :find_by_asin :find_by_id

        def find_by_id!(id)
          record = self.find_by_id(id)
          raise BookNotFoundError.new('Book Not Found') unless record
          record
        end
        alias :find_by_asin! :find_by_id!

        private
        def books_collection
          @collection.map { |r| Book.new(r) }
        end
      end
    end
  end
end<commit_msg>Change to use `record` instead of `r`<commit_after>require File.expand_path('../../models/book', __FILE__)

module Kindle
  module Annotator
    module Models
      class Books
        BookNotFoundError = Class.new(StandardError)

        include Enumerable

        def initialize(collection)
          @collection = Array(collection)
        end

        def each(&block)
          books_collection.each(&block)
        end

        def find_by_id(id)
          self.select { |record| record.id == id }.first
        end
        alias :find_by_asin :find_by_id

        def find_by_id!(id)
          record = self.find_by_id(id)
          raise BookNotFoundError.new('Book Not Found') unless record
          record
        end
        alias :find_by_asin! :find_by_id!

        private
        def books_collection
          @collection.map { |record| Book.new(record) }
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08147321428571429, 'fraction_numerical': 0.0, 'mean_word_length': 1.9059967585089141, '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': '5307838', 'n_tokens_mistral': 527, 'n_tokens_neox': 508, 'n_words': 127}