Sha256: b354d3c1463e04ca3b05fe2acbcc7b5c96dfc3229210dc83dba367694856e448

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require 'delegate'

module MediaTypes
  class Scheme
    class CaseEqualityWithList < SimpleDelegator

      # True for Enumerable#any? {Object#===}
      def ===(other)
        any? { |it| it === other } # rubocop:disable Style/CaseEquality
      end

      def inspect
        "[Scheme::AnyOf(#{__getobj__})]"
      end
    end

    class << self
      # noinspection RubyClassMethodNamingConvention
      ##
      # Allows +it+ to be any of the wrapped +klazzes+
      #
      # @param [Array<Class>] klazzes the classes that are valid for +it+
      # @return [CaseEqualityWithList]
      def AnyOf(*klazzes) # rubocop:disable Naming/MethodName
        CaseEqualityWithList.new(klazzes)
      end
    end

    # noinspection RubyInstanceMethodNamingConvention
    ##
    # Allows +it+ to be any of the wrapped +klazzes+
    #
    # @param [Array<Class>] klazzes the classes that are valid for +it+
    # @return [CaseEqualityWithList]
    def AnyOf(*klazzes) # rubocop:disable Naming/MethodName
      self.class.AnyOf(*klazzes)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
media_types-2.3.0 lib/media_types/scheme/any_of.rb