Sha256: c83e6d2dc626b46e4c3b91ff73e3f09ba5d6e0398b58fd804905ba02ad73f316

Contents?: true

Size: 597 Bytes

Versions: 4

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

module Expire
  # Enhance Integer and String with the methods #all? and #none?
  module RefineAllAndNone
    refine String do
      def all?
        ["-1", "all"].include?(strip.downcase)
      end

      # %w does not work here, I assume there is a problem with "0"
      # rubocop:disable Style/RedundantPercentQ
      def none?
        %q(0 none).include?(strip.downcase)
      end
      # rubocop:enable Style/RedundantPercentQ
    end

    refine Integer do
      def all?
        self == -1
      end

      def none?
        zero?
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
expire-0.2.6 lib/expire/refine_all_and_none.rb
expire-0.2.5 lib/expire/refine_all_and_none.rb
expire-0.2.4 lib/expire/refine_all_and_none.rb
expire-0.2.3 lib/expire/refine_all_and_none.rb