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.



5
6
7
8
9
10
# File 'lib/liquid/forloop_drop.rb', line 5

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.



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

def length
  @length
end

#parentloopObject (readonly)

Returns the value of attribute parentloop.



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

def parentloop
  @parentloop
end

Instance Method Details

#firstObject



35
36
37
# File 'lib/liquid/forloop_drop.rb', line 35

def first
  @index == 0
end

#indexObject



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

def index
  @index + 1
end

#index0Object



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

def index0
  @index
end

#lastObject



39
40
41
# File 'lib/liquid/forloop_drop.rb', line 39

def last
  @index == @length - 1
end

#nameObject



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

def name
  Usage.increment('forloop_drop_name')
  @name
end

#rindexObject



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

def rindex
  @length - @index
end

#rindex0Object



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

def rindex0
  @length - @index - 1
end