Sha256: e15d3f9344a94a56629735552e39e3cb403150b023322f2d36fcf0f987bd64cd

Contents?: true

Size: 394 Bytes

Versions: 12

Compression:

Stored size: 394 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
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
proxes-0.9.2 lib/proxes/helpers/indices.rb
proxes-0.9.1 lib/proxes/helpers/indices.rb
proxes-0.9.0 lib/proxes/helpers/indices.rb
proxes-0.8.6 lib/proxes/helpers/indices.rb
proxes-0.8.5 lib/proxes/helpers/indices.rb
proxes-0.8.4 lib/proxes/helpers/indices.rb
proxes-0.8.3 lib/proxes/helpers/indices.rb
proxes-0.8.2 lib/proxes/helpers/indices.rb
proxes-0.8.1 lib/proxes/helpers/indices.rb
proxes-0.8.0 lib/proxes/helpers/indices.rb
proxes-0.7.1 lib/proxes/helpers/indices.rb
proxes-0.7.0 lib/proxes/helpers/indices.rb