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.



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

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.



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

def length
  @length
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#parentloopObject (readonly)

Returns the value of attribute parentloop.



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

def parentloop
  @parentloop
end

Instance Method Details

#firstObject



71
72
73
# File 'lib/liquid/forloop_drop.rb', line 71

def first
  @index == 0
end

#indexObject



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

def index
  @index + 1
end

#index0Object



47
48
49
# File 'lib/liquid/forloop_drop.rb', line 47

def index0
  @index
end

#lastObject



79
80
81
# File 'lib/liquid/forloop_drop.rb', line 79

def last
  @index == @length - 1
end

#rindexObject



55
56
57
# File 'lib/liquid/forloop_drop.rb', line 55

def rindex
  @length - @index
end

#rindex0Object



63
64
65
# File 'lib/liquid/forloop_drop.rb', line 63

def rindex0
  @length - @index - 1
end