<commit_before>class MetacriticGames::Game

  extend MetacriticGames::Concerns::Nameable::ClassMethods
  extend MetacriticGames::Concerns::Findable::ClassMethods
  extend MetacriticGames::Concerns::Persistable::ClassMethods
  include MetacriticGames::Concerns::Persistable::InstanceMethods

  attr_accessor :name, :developer, :genre, :metascore, :user_score, :game_summary, :critic_reviews, :user_reviews, :release_date, :platform, :url

  @@all = []

  def self.all
    @@all
  end

  # def save
  #   self.class.all << self
  # end

  def initialize
    self.platform = []
    self.url = {}
    # self.genre = []
  end

  def add_platform(platform)
    binding.pry
    platform.add_game(self) unless platform.games.include?(self)
    self.platform << platform unless self.platform.include?(platform)
  end

  def genre= (name)
    @genre = name
    genre.add_game(self) unless self.genre == nil
  end

  def developer= (name)
    self.developer = name
    developer.add_game(self) unless self.developer == nil
  end

  def self.create_games(game_array)
    game_array.each do |game|
      # binding.pry
      if game[:platform] == "XONE"               #metacritic naming for the xboxone does not follow standard pattern
        platform = MetacriticGames::Platform.all.select {|platform| platform.name == "Xbox One"}

        game.tap do |new_game|
          new_game = self.find_or_create_by_name(game[:name])
          binding.pry
          new_game.add_platform(platform.select {|i| i.name == game[:platform]})
          new_game.url = game[:url]

        end
      else
        platform = MetacriticGames::Platform.all.select {|platform| platform.name == game[:platform]}

        game.tap do |new_game|
          new_game = self.find_or_create_by_name(game[:name])
          binding.pry
          new_game.add_platform(platform.select {|i| i.name == game[:platform]})
          new_game.url = game[:url]
        end
      end
    end
  end<commit_msg>changed .select to .find in game #self.create_game(game_array) select was returning an array, not the object itself<commit_after>class MetacriticGames::Game

  extend MetacriticGames::Concerns::Nameable::ClassMethods
  extend MetacriticGames::Concerns::Findable::ClassMethods
  extend MetacriticGames::Concerns::Persistable::ClassMethods
  include MetacriticGames::Concerns::Persistable::InstanceMethods

  attr_accessor :name, :developer, :genre, :metascore, :user_score, :game_summary, :critic_reviews, :user_reviews, :release_date, :platform, :url

  @@all = []

  def self.all
    @@all
  end

  # def save
  #   self.class.all << self
  # end

  def initialize
    self.platform = []
    self.url = {}
    # self.genre = []
  end

  def add_platform(platform)
    binding.pry
    platform.add_game(self) unless platform.games.include?(self)
    self.platform << platform unless self.platform.include?(platform)
  end

  def genre= (name)
    @genre = name
    genre.add_game(self) unless self.genre == nil
  end

  def developer= (name)
    self.developer = name
    developer.add_game(self) unless self.developer == nil
  end

  def self.create_games(game_array)
    game_array.each do |game|
      binding.pry
      if game[:platform] == "XONE"               #metacritic naming for the xboxone does not follow standard pattern
        platform = MetacriticGames::Platform.all.select {|platform| platform.name == "Xbox One"}

        game.tap do |new_game|
          new_game = self.find_or_create_by_name(game[:name])
          # binding.pry
          new_game.add_platform(platform.select {|i| i.name == game[:platform]})
          new_game.url[:"#{game[:platform]}"] = game[:url]

        end
      else
        platform = MetacriticGames::Platform.all.select {|platform| platform.name == game[:platform]}

        game.tap do |new_game|
          new_game = self.find_or_create_by_name(game[:name])
          binding.pry
          new_game.add_platform(platform.select {|i| i.name == game[:platform]})
          new_game.url[:"#{game[:platform]}"] = game[:url]
        end
      end
    end
  end
{'fraction_non_alphanumeric': 0.11737204724409449, 'fraction_numerical': 0.0, 'mean_word_length': 3.203722854188211, 'pattern_counts': {'":': 0, '<': 11, '<?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': '3974116', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1294, 'n_words': 272}