class Piggly::Tags::ConditionalLoopTag

Tracks loops that have a boolean condition in the loop statement (WHILE loops)

Public Instance Methods

ping(value) click to toggle source
# File lib/piggly/tags.rb, line 228
def ping(value)
  case value
  when "t"
    # Loop iterated
    @count += 1
  else
    # Loop terminated
    case @count
    when 0; @pass  = true
    when 1; @once  = true
    else;   @twice = true
    end
    @count = 0

    # This isn't accurate. there needs to be a signal at the end
    # of the loop body to indicate it was reached. Otherwise its
    # possible each iteration restarts early with CONTINUE
    @ends  = true
  end
end