Class: Piggly::Tags::UnconditionalLoopTag

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

Overview

Tracks loops that don’t have a boolean condition in the loop statement (LOOP and FOR 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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractLoopTag

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

Methods inherited from AbstractTag

#initialize, #tap

Constructor Details

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

Class Method Details

.statesObject



254
255
256
257
# File 'lib/piggly/tags.rb', line 254

def self.states
  super.merge \
    0b0100 => "loop always passes through"
end

Instance Method Details

#ping(value) ⇒ Object



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/piggly/tags.rb', line 259

def ping(value)
  case value
  when "t"
    # start of iteration
    @count += 1
  when "@"
    # end of iteration
    @ends = true
  when "f"
    # loop exit
    case @count
    when 0; @pass = true
    when 1; @once = true
    else;  @twice = true
    end
    @count = 0
  end
end