Class: Piggly::Tags::ConditionalLoopTag

Inherits:
AbstractLoopTag show all
Defined in:
lib/piggly/tags.rb

Overview

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

Constant Summary

Constants inherited from AbstractTag

AbstractTag::PATTERN

Instance Attribute Summary

Attributes inherited from AbstractLoopTag

#count, #ends, #once, #pass, #twice

Attributes inherited from AbstractTag

#id

Instance Method Summary collapse

Methods inherited from AbstractLoopTag

#==, #clear, #complete?, #description, #initialize, #state, states, #style, #to_f, #type

Methods inherited from AbstractTag

#initialize, #tap

Constructor Details

This class inherits a constructor from Piggly::Tags::AbstractLoopTag

Instance Method Details

#ping(value) ⇒ Object



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# 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