Permalink
Browse files

Use if instead of when in the response parser to make the code more r…

…eadable.
  • Loading branch information...
1 parent 6df9a0c commit bb7abf1481c3ce1a9de94238ca78e9b25eb6dbd0 @Manfred committed Apr 19, 2012
Showing with 7 additions and 10 deletions.
  1. +7 −10 lib/shl/response.rb
View
@@ -26,18 +26,15 @@ def parse
at = :start
lines = raw.split(NEWLINE)
while(line = lines.shift)
- case at
- when :start
+ if at == :start
@status_line = line
at = :headers
- when :headers
- if line == ''
- at = :body
- else
- key, value = parse_header(line)
- @headers[key] = value
- end
- when :body
+ elsif at == :headers && line == ''
+ at = :body
+ elsif at == :headers
+ key, value = parse_header(line)
+ @headers[key] = value
+ elsif at == :body
@body << line
end
end

0 comments on commit bb7abf1

Please sign in to comment.