class Swa::CLI::Selector

Public Class Methods

new() click to toggle source
# File lib/swa/cli/selector.rb, line 6
def initialize
  @predicates = []
end

Public Instance Methods

add(&block) click to toggle source
# File lib/swa/cli/selector.rb, line 10
def add(&block)
  @predicates << block
end
apply(collection) click to toggle source
# File lib/swa/cli/selector.rb, line 20
def apply(collection)
  collection.lazy.select(&method(:call))
end
call(subject) click to toggle source
# File lib/swa/cli/selector.rb, line 14
def call(subject)
  @predicates.all? do |predicate|
    predicate.call(subject)
  end
end