Sha256: f25dea14c88b09fede4f551657058c07495c62948dad0ad04c44d3e7308e9026
Contents?: true
Size: 579 Bytes
Versions: 9
Compression:
Stored size: 579 Bytes
Contents
module SimCtl class List < Array # Filters an array of objects by a given hash. The keys of # the hash must be methods implemented by the objects. The # values of the hash are compared to the values the object # returns when calling the methods. # # @param filter [Hash] the filters that should be applied # @return [Array] the filtered array. def where(filter) select do |item| matches = true filter.each do |key, value| matches &= item.send(key) == value end matches end end end end
Version data entries
9 entries across 9 versions & 1 rubygems