module CardsLib::Refinements::InjectWhile

Public Instance Methods

inject_while?(m) click to toggle source
# File lib/cards_lib/refinements.rb, line 4
def inject_while?(m)
  result, *array = dup
  loop do
    break if array.empty?
    other = array.shift

    result = result.send(m, other)
    return false unless result
  end
  true
end