Class: Liquid::ForloopDrop

Inherits:
Drop
  • Object
show all
Defined in:
lib/liquid/forloop_drop.rb

Instance Attribute Summary collapse

Attributes inherited from Drop

#context

Instance Method Summary collapse

Methods inherited from Drop

#inspect, invokable?, invokable_methods, #invoke_drop, #key?, #liquid_method_missing, #to_liquid, #to_s

Constructor Details

#initialize(name, length, parentloop) ⇒ ForloopDrop

Returns a new instance of ForloopDrop.



3
4
5
6
7
8
# File 'lib/liquid/forloop_drop.rb', line 3

def initialize(name, length, parentloop)
  @name = name
  @length = length
  @parentloop = parentloop
  @index = 0
end

Instance Attribute Details

#lengthObject (readonly)

Returns the value of attribute length.



10
11
12
# File 'lib/liquid/forloop_drop.rb', line 10

def length
  @length
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/liquid/forloop_drop.rb', line 10

def name
  @name
end

#parentloopObject (readonly)

Returns the value of attribute parentloop.



10
11
12
# File 'lib/liquid/forloop_drop.rb', line 10

def parentloop
  @parentloop
end

Instance Method Details

#firstObject



28
29
30
# File 'lib/liquid/forloop_drop.rb', line 28

def first
  @index == 0
end

#indexObject



12
13
14
# File 'lib/liquid/forloop_drop.rb', line 12

def index
  @index + 1
end

#index0Object



16
17
18
# File 'lib/liquid/forloop_drop.rb', line 16

def index0
  @index
end

#lastObject



32
33
34
# File 'lib/liquid/forloop_drop.rb', line 32

def last
  @index == @length - 1
end

#rindexObject



20
21
22
# File 'lib/liquid/forloop_drop.rb', line 20

def rindex
  @length - @index
end

#rindex0Object



24
25
26
# File 'lib/liquid/forloop_drop.rb', line 24

def rindex0
  @length - @index - 1
end