Class: AtCoderFriends::Parser::FormatParser::Iterator
- Inherits:
-
Object
- Object
- AtCoderFriends::Parser::FormatParser::Iterator
- Defined in:
- lib/at_coder_friends/parser/format_parser.rb
Overview
Iterates through elements of an array
Instance Method Summary collapse
-
#initialize(array) ⇒ Iterator
constructor
A new instance of Iterator.
- #next ⇒ Object
- #next? ⇒ Boolean
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
#next ⇒ Object
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
16 17 18 |
# File 'lib/at_coder_friends/parser/format_parser.rb', line 16 def next? @i < @array.size end |