mirror of
https://github.com/kemko/liquid.git
synced 2026-01-03 16:55:40 +03:00
* Add ForceEqualSignAlignment to .rubocop.yml * Revert ForceEqualSignAlignment cop * Update method alignment * Undo addition of whitespace to improve readability * Fix missing alignment
65 lines
815 B
Ruby
65 lines
815 B
Ruby
# frozen_string_literal: true
|
|
|
|
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
|