Class: Boxcab::ActionView::Helpers::BoxcabViewListIterator

Inherits:
Object
  • Object
show all
Defined in:
lib/boxcab/action_view/helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size = 0, index = 0) ⇒ BoxcabViewListIterator

Returns a new instance of BoxcabViewListIterator.



95
96
97
# File 'lib/boxcab/action_view/helpers.rb', line 95

def initialize(size = 0, index = 0)
  @size, @index = size, index
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



93
94
95
# File 'lib/boxcab/action_view/helpers.rb', line 93

def index
  @index
end

#sizeObject (readonly)

Returns the value of attribute size.



93
94
95
# File 'lib/boxcab/action_view/helpers.rb', line 93

def size
  @size
end

Instance Method Details

#change(index) ⇒ Object



111
112
113
114
# File 'lib/boxcab/action_view/helpers.rb', line 111

def change(index)
  @index = index
  self
end

#every?(n) ⇒ Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/boxcab/action_view/helpers.rb', line 107

def every?(n)
  !first? && !last? && ((@index + 1) % n) == 0
end

#first?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/boxcab/action_view/helpers.rb', line 99

def first?
  @index == 0
end

#last?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/boxcab/action_view/helpers.rb', line 103

def last?
  @index == @size - 1
end