Skip to content

Instantly share code, notes, and snippets.

@nitrogenlogic
Created July 12, 2012 14:42
Show Gist options
  • Save nitrogenlogic/3098541 to your computer and use it in GitHub Desktop.
Save nitrogenlogic/3098541 to your computer and use it in GitHub Desktop.
Simplified parser for xAP messages
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