add yard tags

This commit is contained in:
Jake Olney
2022-06-27 15:10:21 -04:00
committed by Melanie Wang
parent eb70bb9b87
commit f3aa5fbd7c
21 changed files with 820 additions and 216 deletions
+37 -1
View File
@@ -1,6 +1,11 @@
# frozen_string_literal: true
module Liquid
# @liquid_public_docs
# @liquid_type object
# @liquid_name forloop
# @liquid_summary
# The `forloop` object contains information about a parent [`for` loop](/api/liquid/tags#for).
class ForloopDrop < Drop
def initialize(name, length, parentloop)
@name = name
@@ -9,33 +14,64 @@ module Liquid
@index = 0
end
attr_reader :length, :parentloop
# @liquid_public_docs
# @liquid_name forloop.length
# @liquid_summary
# The number of iterations.
# @liquid_return [number]
attr_reader :length
attr_reader :parentloop
def name
Usage.increment('forloop_drop_name')
@name
end
# @liquid_public_docs
# @liquid_summary
# The 1-based index of the current iteration.
# @liquid_return [number]
def index
@index + 1
end
# @liquid_public_docs
# @liquid_summary
# The 0-based index of the current iteration.
# @liquid_return [number]
def index0
@index
end
# @liquid_public_docs
# @liquid_summary
# The 1-based index of the current iteration, in reverse order.
# @liquid_return [number]
def rindex
@length - @index
end
# @liquid_public_docs
# @liquid_summary
# The 0-based index of the current iteration, in reverse order.
# @liquid_return [number]
def rindex0
@length - @index - 1
end
# @liquid_public_docs
# @liquid_summary
# Returns `true` if the current iteration is the first. Returns `false` if not.
# @liquid_return [boolean]
def first
@index == 0
end
# @liquid_public_docs
# @liquid_summary
# Returns `true` if the current iteration is the last. Returns `false` if not.
# @liquid_return [boolean]
def last
@index == @length - 1
end