Sha256: ef1210df1f4dd71800055816f4a5cf299ad293be4aaea52a0f7132e4a73d7c9f

Contents?: true

Size: 423 Bytes

Versions: 6

Compression:

Stored size: 423 Bytes

Contents

# frozen_string_literal: true

module ProxES
  module Helpers
    module Indices
      def filter(asked, against)
        return against.map { |a| a.gsub(/\.\*/, '*') } if asked == ['*'] || asked == [] || asked.nil?

        answer = []
        against.each do |pattern|
          answer.concat(asked.select { |idx| idx =~ /#{pattern}/ })
        end
        answer.count > 0 ? answer : against
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
proxes-0.6.1 lib/proxes/helpers/indices.rb
proxes-0.6.0 lib/proxes/helpers/indices.rb
proxes-0.5.2 lib/proxes/helpers/indices.rb
proxes-0.5.1 lib/proxes/helpers/indices.rb
proxes-0.5.0 lib/proxes/helpers/indices.rb
proxes-0.4.4 lib/proxes/helpers/indices.rb