Class: Aurfy::Parser
- Inherits:
-
Object
- Object
- Aurfy::Parser
- Defined in:
- lib/aurfy/parser.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
-
#initialize(body) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(body) ⇒ Parser
Returns a new instance of Parser.
5 6 7 |
# File 'lib/aurfy/parser.rb', line 5 def initialize(body) @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/aurfy/parser.rb', line 3 def body @body end |
Instance Method Details
#parse ⇒ Object
9 10 11 12 13 |
# File 'lib/aurfy/parser.rb', line 9 def parse params = body.split("&").map { |p| p.split("=") } params = params.map { |p| p.length >= 2 ? p : p.push("") } params.to_h.each_with_object({}) { |(k, v), a| a[k.to_s.to_sym] = v } end |