Sha256: 1103d0576623d260ec44b8f885a4ee4e39a176b5bd0d9870d9f9c13cb6cf469c

Contents?: true

Size: 775 Bytes

Versions: 11

Compression:

Stored size: 775 Bytes

Contents

module Liquid
  class TablerowloopDrop < Drop
    def initialize(length, cols)
      @length = length
      @row = 1
      @col = 1
      @cols = cols
      @index = 0
    end

    attr_reader :length, :col, :row

    def index
      @index + 1
    end

    def index0
      @index
    end

    def col0
      @col - 1
    end

    def rindex
      @length - @index
    end

    def rindex0
      @length - @index - 1
    end

    def first
      @index == 0
    end

    def last
      @index == @length - 1
    end

    def col_first
      @col == 1
    end

    def col_last
      @col == @cols
    end

    protected

    def increment!
      @index += 1

      if @col == @cols
        @col = 1
        @row += 1
      else
        @col += 1
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
liquid-4.0.4 lib/liquid/tablerowloop_drop.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/liquid-4.0.3/lib/liquid/tablerowloop_drop.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/liquid-4.0.3/lib/liquid/tablerowloop_drop.rb
liquid-4.0.3 lib/liquid/tablerowloop_drop.rb
liquid-4.0.2 lib/liquid/tablerowloop_drop.rb
liquid-4-0-2-4.0.2 lib/liquid/tablerowloop_drop.rb
liquid-4.0.1 lib/liquid/tablerowloop_drop.rb
liquid-4.0.0 lib/liquid/tablerowloop_drop.rb
liquid-4.0.0.rc3 lib/liquid/tablerowloop_drop.rb
liquid-4.0.0.rc2 lib/liquid/tablerowloop_drop.rb
liquid-4.0.0.rc1 lib/liquid/tablerowloop_drop.rb