<commit_before>require 'singleton'
require 'dhun_ext'
module Dhun
  class Player
    include Singleton

    attr_reader :queue
    attr_reader :status
    attr_reader :current

    attr_reader :logger

    def initialize
      @queue = []
      @logger = Logger.instance
      @status = :stopped
    end

    def empty_queue
      stop
      @queue.clear
    end

    
    def play_files(files)
      if files.empty?
        logger.log "Empty Queue"
      else
        stop
        empty_queue
        files.each { |f| self.queue.push f }
        play
      end
    end

    def enqueue(files)
      files.each { |f| self.queue.push f }
      play
    end

    def play
      return if @status == :playing
      @status = :playing
      @player_thread = Thread.new do
        while  @status == :playing and !queue.empty?          
          @current = @queue.shift
          logger.log "Playing #{@current}"<commit_msg>Fixing play with method with proper conditions<commit_after>require 'singleton'
require 'dhun_ext'
module Dhun
  class Player
    include Singleton

    attr_reader :queue
    attr_reader :status
    attr_reader :current

    attr_reader :logger

    def initialize
      @queue = []
      @logger = Logger.instance
      @status = :stopped
    end

    def empty_queue
      stop
      @queue.clear
    end

    
    def play_files(files)
      if files.empty?
        logger.log "Empty Queue"
      else
        stop
        empty_queue
        files.each { |f| self.queue.push f }
        play
      end
    end

    def enqueue(files)
      files.each { |f| self.queue.push f }
      play
    end

    def play
      return unless self.status == :stopped
      @status = :playing
      @player_thread = Thread.new do
        while  @status == :playing and !queue.empty?          
          @current = @queue.shift
          logger.log "Playing #{@current}"
{'fraction_non_alphanumeric': 0.07876530069185737, 'fraction_numerical': 0.0, 'mean_word_length': 1.81437125748503, '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': '4779578', 'n_tokens_mistral': 573, 'n_tokens_neox': 549, 'n_words': 159}