Class: Liquor::Builtins::ForLoop
- Inherits:
-
Object
- Object
- Liquor::Builtins::ForLoop
- Includes:
- External
- Defined in:
- lib/liquor/stdlib/builtin_tags.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Instance Method Summary collapse
-
#initialize(length) ⇒ ForLoop
constructor
A new instance of ForLoop.
- #is_first ⇒ Object
- #is_last ⇒ Object
- #next! ⇒ Object
- #rindex ⇒ Object
Methods included from External
Constructor Details
#initialize(length) ⇒ ForLoop
Returns a new instance of ForLoop.
39 40 41 42 |
# File 'lib/liquor/stdlib/builtin_tags.rb', line 39 def initialize(length) @length = length @index = 0 end |
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
45 46 47 |
# File 'lib/liquor/stdlib/builtin_tags.rb', line 45 def index @index end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
44 45 46 |
# File 'lib/liquor/stdlib/builtin_tags.rb', line 44 def length @length end |
Instance Method Details
#is_first ⇒ Object
55 56 57 |
# File 'lib/liquor/stdlib/builtin_tags.rb', line 55 def is_first @index == 0 end |
#is_last ⇒ Object
59 60 61 |
# File 'lib/liquor/stdlib/builtin_tags.rb', line 59 def is_last @index == @length - 1 end |
#next! ⇒ Object
47 48 49 |
# File 'lib/liquor/stdlib/builtin_tags.rb', line 47 def next! @index += 1 end |
#rindex ⇒ Object
51 52 53 |
# File 'lib/liquor/stdlib/builtin_tags.rb', line 51 def rindex @length - @index - 1 end |