Class: RubyVibe::Response
- Inherits:
-
Object
- Object
- RubyVibe::Response
- Defined in:
- lib/ruby-vibe/response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #parse ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
6 7 8 |
# File 'lib/ruby-vibe/response.rb', line 6 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/ruby-vibe/response.rb', line 4 def response @response end |
Class Method Details
.parse(response) ⇒ Object
11 12 13 14 |
# File 'lib/ruby-vibe/response.rb', line 11 def parse(response) response = new(response) response.parse end |
Instance Method Details
#parse ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ruby-vibe/response.rb', line 17 def parse success = true = nil hash = JSON.parse(response.body) unless hash.dig('status').to_i == 0 success = false = hash.dig('status_message') end Struct.new(:success?, :se, :error_message).new(success, hash, ) end |