Class: Minecraft::JSONAPI::Response
- Inherits:
-
Object
- Object
- Minecraft::JSONAPI::Response
- Defined in:
- lib/minecraft-jsonapi/response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(data) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(data) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/minecraft-jsonapi/response.rb', line 6 def initialize(data) data = JSON.parse data # Was this a multi-call? if data["source"].is_a? Array @result = data["success"].map { |r| r["result"] } @source = data["success"].map { |r| r["source"] } @response = data["success"].map { |r| r["success"] } else @result = data["result"] @source = data["source"] @response = data["success"] end end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/minecraft-jsonapi/response.rb', line 4 def response @response end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
4 5 6 |
# File 'lib/minecraft-jsonapi/response.rb', line 4 def result @result end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
4 5 6 |
# File 'lib/minecraft-jsonapi/response.rb', line 4 def source @source end |