Sha256: 642e9e8491de29db55e08172736a2faee20b39fad3a5e1f9c368b089e0407788

Contents?: true

Size: 683 Bytes

Versions: 5

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

module Liquid
  class ForloopDrop < Drop
    def initialize(name, length, parentloop)
      @name       = name
      @length     = length
      @parentloop = parentloop
      @index      = 0
    end

    attr_reader :length, :parentloop

    def name
      Usage.increment('forloop_drop_name')
      @name
    end

    def index
      @index + 1
    end

    def index0
      @index
    end

    def rindex
      @length - @index
    end

    def rindex0
      @length - @index - 1
    end

    def first
      @index == 0
    end

    def last
      @index == @length - 1
    end

    protected

    def increment!
      @index += 1
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
liquid-5.3.0 lib/liquid/forloop_drop.rb
liquid-5.2.0 lib/liquid/forloop_drop.rb
liquid-5.1.0 lib/liquid/forloop_drop.rb
liquid-5.0.1 lib/liquid/forloop_drop.rb
liquid-5.0.0 lib/liquid/forloop_drop.rb