Sha256: f0599b467cf6a3e2752dd167c88f4d3aeac408ace6426482415a23d069f1f928

Contents?: true

Size: 1.11 KB

Versions: 15

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module LittleWeasel
  module Metadata
    # This class provides a container for the results of the
    # InvalidWordsService service.
    class InvalidWordsServiceResults
      attr_accessor :current_invalid_word_bytesize
      attr_reader :max_invalid_words_bytesize

      def initialize(max_invalid_words_bytesize_on:,
        current_invalid_word_bytesize:, max_invalid_words_bytesize:)

        self.max_invalid_words_bytesize_on = max_invalid_words_bytesize_on
        self.current_invalid_word_bytesize = current_invalid_word_bytesize
        self.max_invalid_words_bytesize = max_invalid_words_bytesize
      end

      def on?
        max_invalid_words_bytesize_on
      end

      def off?
        !on?
      end

      def value
        max_invalid_words_bytesize
      end

      def value_exceeded?
        on? && current_invalid_word_bytesize > max_invalid_words_bytesize
      end

      def cache_invalid_words?
        on? && !value_exceeded?
      end

      private

      attr_accessor :max_invalid_words_bytesize_on
      attr_writer :max_invalid_words_bytesize
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
LittleWeasel-5.0.13 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.12 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.11 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.10 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.9 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.8 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.7 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.6 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.5 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.4 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.3 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.2 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.1 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-5.0.0 lib/LittleWeasel/metadata/invalid_words_service_results.rb
LittleWeasel-4.0.0 lib/LittleWeasel/metadata/invalid_words_service_results.rb