class Liquid::TablerowloopDrop

@liquid_public_docs @liquid_type object @liquid_name tablerowloop @liquid_summary

Information about a parent [`tablerow` loop](/api/liquid/tags#tablerow).

Attributes

col[R]

@liquid_public_docs @liquid_summary

The 1-based index of the current column.

@liquid_return [number]

length[R]

@liquid_public_docs @liquid_summary

The total number of iterations in the loop.

@liquid_return [number]

row[R]

@liquid_public_docs @liquid_summary

The 1-based index of current row.

@liquid_return [number]

Public Class Methods

new(length, cols) click to toggle source
# File lib/liquid/tablerowloop_drop.rb, line 10
def initialize(length, cols)
  @length = length
  @row    = 1
  @col    = 1
  @cols   = cols
  @index  = 0
end

Public Instance Methods

col0() click to toggle source

@liquid_public_docs @liquid_summary

The 0-based index of the current column.

@liquid_return [number]

# File lib/liquid/tablerowloop_drop.rb, line 56
def col0
  @col - 1
end
col_first() click to toggle source

@liquid_public_docs @liquid_summary

Returns `true` if the current column is the first in the row. Returns `false` if not.

@liquid_return [boolean]

# File lib/liquid/tablerowloop_drop.rb, line 96
def col_first
  @col == 1
end
col_last() click to toggle source

@liquid_public_docs @liquid_summary

Returns `true` if the current column is the last in the row. Returns `false` if not.

@liquid_return [boolean]

# File lib/liquid/tablerowloop_drop.rb, line 104
def col_last
  @col == @cols
end
first() click to toggle source

@liquid_public_docs @liquid_summary

Returns `true` if the current iteration is the first. Returns `false` if not.

@liquid_return [boolean]

# File lib/liquid/tablerowloop_drop.rb, line 80
def first
  @index == 0
end
index() click to toggle source

@liquid_public_docs @liquid_summary

The 1-based index of the current iteration.

@liquid_return [number]

# File lib/liquid/tablerowloop_drop.rb, line 40
def index
  @index + 1
end
index0() click to toggle source

@liquid_public_docs @liquid_summary

The 0-based index of the current iteration.

@liquid_return [number]

# File lib/liquid/tablerowloop_drop.rb, line 48
def index0
  @index
end
last() click to toggle source

@liquid_public_docs @liquid_summary

Returns `true` if the current iteration is the last. Returns `false` if not.

@liquid_return [boolean]

# File lib/liquid/tablerowloop_drop.rb, line 88
def last
  @index == @length - 1
end
rindex() click to toggle source

@liquid_public_docs @liquid_summary

The 1-based index of the current iteration, in reverse order.

@liquid_return [number]

# File lib/liquid/tablerowloop_drop.rb, line 64
def rindex
  @length - @index
end
rindex0() click to toggle source

@liquid_public_docs @liquid_summary

The 0-based index of the current iteration, in reverse order.

@liquid_return [number]

# File lib/liquid/tablerowloop_drop.rb, line 72
def rindex0
  @length - @index - 1
end

Protected Instance Methods

increment!() click to toggle source
# File lib/liquid/tablerowloop_drop.rb, line 110
def increment!
  @index += 1

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