Class: Solid::LiquidExtensions::ForLoop

Inherits:
Liquid::Drop
  • Object
show all
Defined in:
lib/solid/liquid_extensions/for_tag.rb

Direct Known Subclasses

PaginatedForLoop

Instance Method Summary collapse

Constructor Details

#initialize(collection) ⇒ ForLoop

Returns a new instance of ForLoop.



52
53
54
55
# File 'lib/solid/liquid_extensions/for_tag.rb', line 52

def initialize(collection)
  @collection = collection
  @index0 = 0
end

Instance Method Details

#firstObject



77
78
79
# File 'lib/solid/liquid_extensions/for_tag.rb', line 77

def first
  index0 == 0
end

#inc!Object



85
86
87
# File 'lib/solid/liquid_extensions/for_tag.rb', line 85

def inc!
   @index0 += 1
end

#indexObject



61
62
63
# File 'lib/solid/liquid_extensions/for_tag.rb', line 61

def index
  index0 + 1
end

#index0Object



57
58
59
# File 'lib/solid/liquid_extensions/for_tag.rb', line 57

def index0
  @index0
end

#lastObject



81
82
83
# File 'lib/solid/liquid_extensions/for_tag.rb', line 81

def last
  index == length
end

#lengthObject



73
74
75
# File 'lib/solid/liquid_extensions/for_tag.rb', line 73

def length
  @collection.length
end

#rindexObject



65
66
67
# File 'lib/solid/liquid_extensions/for_tag.rb', line 65

def rindex
  length - index0
end

#rindex0Object



69
70
71
# File 'lib/solid/liquid_extensions/for_tag.rb', line 69

def rindex0
  length - index0 - 1
end