Class: AtCoderFriends::Iterator

Inherits:
Object
  • Object
show all
Defined in:
lib/at_coder_friends/format_parser.rb

Overview

Iterates through elements of an array

Instance Method Summary collapse

Constructor Details

#initialize(array) ⇒ Iterator

Returns a new instance of Iterator.



6
7
8
9
# File 'lib/at_coder_friends/format_parser.rb', line 6

def initialize(array)
  @array = array
  @i = 0
end

Instance Method Details

#nextObject



15
16
17
18
19
# File 'lib/at_coder_friends/format_parser.rb', line 15

def next
  ret = @array[@i]
  @i += 1
  ret
end

#next?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/at_coder_friends/format_parser.rb', line 11

def next?
  @i < @array.size
end