lib/haml_lint/utils.rb
# Find all consecutive nodes satisfying the given {Proc} of a minimum size
# and yield each group.
#
# @param items [Array]
# @param min_size [Fixnum] minimum number of consecutive items before
#   yielding
# @param satisfies [Proc] function that takes an item and returns true/false
Find all consecutive nodes satisfying the given {Proc} of a minimum size
and yield each group.
Find all consecutive nodes satisfying the given { Proc } of a minimum size and yield each group .
def find_consecutive(items, min_size, satisfies)
      current = -1
      while (current += 1) < items.count
        next unless satisfies[items[current]]
        count = count_consecutive(items, current, satisfies)
        next unless count >= min_size
        yield items[current...(current + count)]
        current += count 
      end
    end
def find_consecutive ( items , min_size , satisfies ) current = - 1 while ( current += 1 ) < items . count next unless satisfies [ items [ current ] ] count = count_consecutive ( items , current , satisfies ) next unless count >= min_size yield items [ current ... ( current + count ) ] current += count end end
Find all consecutive nodes satisfying the given {Proc} of a minimum size
and yield each group.
Find all consecutive nodes satisfying the given { Proc } of a minimum size and yield each group .
# Yield the chunk of consecutive items # Skip this patch of consecutive items to find more
items
min_size
minimum number of consecutive items before yielding
minimum number of consecutive items before yielding
satisfies
function that takes an item and returns true/false
function that takes an item and returns true / false
None