Sha256: 5f613fd83c6ebddd2e02cbf85f40ffb0f4464b7f5b25b5d0b20579352d4aa208

Contents?: true

Size: 380 Bytes

Versions: 3

Compression:

Stored size: 380 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 == []

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
proxes-0.4.3 lib/proxes/helpers/indices.rb
proxes-0.4.2 lib/proxes/helpers/indices.rb
proxes-0.4.1 lib/proxes/helpers/indices.rb