Created
July 12, 2012 14:42
-
-
Save nitrogenlogic/3098541 to your computer and use it in GitHub Desktop.
Simplified parser for xAP messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.simple_parse(data) | |
Hash[*data.split(/}\n?/).map {|v| | |
bl = v.split("\n{\n") | |
bl[1] = Hash[*bl[1].split("\n").map {|v2| | |
pair = v2.split(/[=!]/, 2) | |
pair[1] = [pair[1]].pack 'H*' if v2 =~ /^[^=!]+!/ | |
pair | |
}.flatten!] | |
bl | |
}.flatten!(1)] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment