<commit_before>require 'cgi'

module IronMQ

  class Queue < ResponseBase
    attr_reader :name, :raw

    def initialize(client, queue_name)
      @client = client
      @name = queue_name
    end

    def info
      load
    end

    # this is only run once if it hasn't been called before unless force is true, then it will force reload.
    def load
      reload if @raw.nil?

      @raw['queue']
    end

    def reload
      @raw = call_api_and_parse_response(:get, '', {}, false, true)
      self
    end

    def id
      load['id']
    end

    def size
      load['size'].to_i
    end

    def total_messages
      load['total_messages'].to_i
    end

    def type
      load['type']
    end

    def push_queue?
      ['multicast', 'unicast'].include?(type)
    end

    def push_info
      load['push']
    end

    def update(options={})
      call_api_and_parse_response(:put, '', {queue: options})
    end

    alias_method :update_queue, :update

    def clear
      call_api_and_parse_response(:delete, '/messages', {}, false, true)
    end

    alias_method :clear_queue, :clear
<commit_msg>load queue info directly from update() call response<commit_after>require 'cgi'

module IronMQ

  class Queue < ResponseBase
    attr_reader :name, :raw

    def initialize(client, queue_name)
      @client = client
      @name = queue_name
    end

    def info
      load
    end

    # this is only run once if it hasn't been called before unless force is true, then it will force reload.
    def load
      reload if @raw.nil?

      @raw['queue']
    end

    def reload
      @raw = call_api_and_parse_response(:get, '', {}, false, true)
      self
    end

    def id
      load['id']
    end

    def size
      load['size'].to_i
    end

    def total_messages
      load['total_messages'].to_i
    end

    def type
      load['type']
    end

    def push_queue?
      ['multicast', 'unicast'].include?(type)
    end

    def push_info
      load['push']
    end

    def update(options={})
      res = call_api_and_parse_response(:put, '', {queue: options})
      @raw = res.raw
      res
    end

    alias_method :update_queue, :update

    def clear
      call_api_and_parse_response(:delete, '/messages', {}, false, true)
    end

    alias_method :clear_queue, :clear

{'fraction_non_alphanumeric': 0.0967741935483871, 'fraction_numerical': 0.0, 'mean_word_length': 2.2738944365192584, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5485255', 'n_tokens_mistral': 750, 'n_tokens_neox': 709, 'n_words': 213}