Class: Liquor::Builtins::ForLoop

Inherits:
Object
  • Object
show all
Includes:
External
Defined in:
lib/liquor/stdlib/builtin_tags.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from External

included, #liquor_send

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

#indexObject

Returns the value of attribute index



45
46
47
# File 'lib/liquor/stdlib/builtin_tags.rb', line 45

def index
  @index
end

#lengthObject (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_firstObject



55
56
57
# File 'lib/liquor/stdlib/builtin_tags.rb', line 55

def is_first
  @index == 0
end

#is_lastObject



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

#rindexObject



51
52
53
# File 'lib/liquor/stdlib/builtin_tags.rb', line 51

def rindex
  @length - @index - 1
end