Skip to content

Commit 5ee8d45

Browse files
committed
Implement Parser#symbol
1 parent 7880294 commit 5ee8d45

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/parser.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Parser
2-
class A_COMMAND; end
3-
class C_COMMAND; end
4-
class L_COMMAND; end
2+
A_COMMAND = Object.new
3+
C_COMMAND = Object.new
4+
L_COMMAND = Object.new
55

66
def initialize(input)
77
@lines = split_lines(input)
@@ -25,6 +25,15 @@ def command_type
2525
end
2626
end
2727

28+
def symbol
29+
case command_type
30+
when A_COMMAND
31+
current[1..-1]
32+
else
33+
current[1..-2]
34+
end
35+
end
36+
2837
private
2938

3039
attr_reader :lines, :current

0 commit comments

Comments
 (0)