Skip to content
Browse files

simplify array/hash logic

  • Loading branch information...
1 parent ceb7f3b commit 6e1323801ebaa524a8b943f04c81481869ded185 @rkh committed May 15, 2011
Showing with 4 additions and 12 deletions.
  1. +4 −12 lib/otnetstring.rb
View
16 lib/otnetstring.rb
@@ -15,18 +15,10 @@ def self.parse(io)
when '~' then nil
when '!' then io.read(length) == 'true'
when '[', '{'
- hash = byte == "{"
- object = hash ? {} : []
- start = io.pos
- while io.pos - start < length
- value = parse(io)
- if hash
- object[value] = parse(io)
- else
- object << value
- end
- end
- object
+ array = []
+ start = io.pos
+ array << parse(io) while io.pos - start < length
+ byte == "{" ? Hash[*array] : array
end
end

0 comments on commit 6e13238

Please sign in to comment.
Something went wrong with that request. Please try again.