Class: AtCoderFriends::Parser::FormatParser::Iterator

Inherits:
Object
  • Object
show all
Defined in:
lib/at_coder_friends/parser/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.



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

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

Instance Method Details

#nextObject



20
21
22
23
24
# File 'lib/at_coder_friends/parser/format_parser.rb', line 20

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

#next?Boolean

Returns:

  • (Boolean)


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

def next?
  @i < @array.size
end