Class: Liquid2::ForLoop
- Inherits:
-
Object
- Object
- Liquid2::ForLoop
- Defined in:
- lib/liquid2/nodes/tags/for.rb
Overview
for loop helper variables.
Constant Summary collapse
- KEYS =
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parentloop ⇒ Object
readonly
Returns the value of attribute parentloop.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #fetch(key, default = :undefined) ⇒ Object
- #first ⇒ Object
- #index ⇒ Object
- #index0 ⇒ Object
-
#initialize(name, length, parent_loop) ⇒ ForLoop
constructor
A new instance of ForLoop.
- #key?(key) ⇒ Boolean
- #last ⇒ Object
- #next ⇒ Object
- #rindex ⇒ Object
- #rindex0 ⇒ Object
Constructor Details
#initialize(name, length, parent_loop) ⇒ ForLoop
Returns a new instance of ForLoop.
124 125 126 127 128 129 |
# File 'lib/liquid2/nodes/tags/for.rb', line 124 def initialize(name, length, parent_loop) @name = name @length = length @parentloop = parent_loop @index = -1 end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
110 111 112 |
# File 'lib/liquid2/nodes/tags/for.rb', line 110 def length @length end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
110 111 112 |
# File 'lib/liquid2/nodes/tags/for.rb', line 110 def name @name end |
#parentloop ⇒ Object (readonly)
Returns the value of attribute parentloop.
110 111 112 |
# File 'lib/liquid2/nodes/tags/for.rb', line 110 def parentloop @parentloop end |
Instance Method Details
#[](key) ⇒ Object
135 136 137 |
# File 'lib/liquid2/nodes/tags/for.rb', line 135 def [](key) send(key) if KEYS.member?(key) end |
#fetch(key, default = :undefined) ⇒ Object
139 140 141 142 143 144 145 |
# File 'lib/liquid2/nodes/tags/for.rb', line 139 def fetch(key, default = :undefined) if KEYS.member?(key) send(key) else default end end |
#first ⇒ Object
152 |
# File 'lib/liquid2/nodes/tags/for.rb', line 152 def first = @index.zero? |
#index ⇒ Object
148 |
# File 'lib/liquid2/nodes/tags/for.rb', line 148 def index = @index + 1 |
#index0 ⇒ Object
149 |
# File 'lib/liquid2/nodes/tags/for.rb', line 149 def index0 = @index |
#key?(key) ⇒ Boolean
131 132 133 |
# File 'lib/liquid2/nodes/tags/for.rb', line 131 def key?(key) KEYS.member?(key) end |
#last ⇒ Object
153 |
# File 'lib/liquid2/nodes/tags/for.rb', line 153 def last = @index == @length - 1 |
#next ⇒ Object
147 |
# File 'lib/liquid2/nodes/tags/for.rb', line 147 def next = @index += 1 |
#rindex ⇒ Object
150 |
# File 'lib/liquid2/nodes/tags/for.rb', line 150 def rindex = @length - @index |
#rindex0 ⇒ Object
151 |
# File 'lib/liquid2/nodes/tags/for.rb', line 151 def rindex0 = @length - @index - 1 |