Module: Rubyplat::Utils::Parser
- Included in:
- Responses::Response
- Defined in:
- lib/rubyplat/utils/parser.rb
Instance Method Summary collapse
-
#parse(response_body) ⇒ Hash
Hash of key value hashes.
Instance Method Details
#parse(response_body) ⇒ Hash
Returns hash of key value hashes.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rubyplat/utils/parser.rb', line 7 def parse(response_body) regex = /BEGIN\r\n(.*)END\r\n/m body = response_body.match(regex)[1].scan(/(?<key>.*)=(?<value>.*)\r\n/) params = {} body.each do |param| k,v = param params[k.strip.downcase.to_sym] = v end params end |