Skip to content

Commit 5ed0fe0

Browse files
committed
Implement Parser#advance
1 parent d6fe9f0 commit 5ed0fe0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/parser.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
class Parser
2-
attr_reader :input
2+
attr_reader :lines
33

44
def initialize(input)
5-
@input = input
5+
input = input.gsub(%r{//.*$}, '').strip
6+
@lines = input.lines
67
end
78

89
def has_more_commands?
9-
!input.gsub(%r{//.*$}, '').strip.empty?
10+
!@lines.empty?
11+
end
12+
13+
def advance
14+
@lines.shift
1015
end
1116
end

0 commit comments

Comments
 (0)