Sha256: 62567fd691c5d4e4af79dcb17afdd1696f02a1241a9181ff755ef21bd2b960b5

Contents?: true

Size: 657 Bytes

Versions: 3

Compression:

Stored size: 657 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?
        return true if ['-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?
        return true if %q(0 none).include?(strip.downcase)
      end
      # rubocop:enable Style/RedundantPercentQ
    end

    refine Integer do
      def all?
        return true if self == -1
      end

      def none?
        return true if zero?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
expire-0.2.2 lib/expire/refine_all_and_none.rb
expire-0.2.1 lib/expire/refine_all_and_none.rb
expire-0.2.0 lib/expire/refine_all_and_none.rb