Class: Minecraft::JSONAPI::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/minecraft-jsonapi/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/minecraft-jsonapi/response.rb', line 4

def response
  @response
end

#resultObject (readonly)

Returns the value of attribute result.



4
5
6
# File 'lib/minecraft-jsonapi/response.rb', line 4

def result
  @result
end

#sourceObject (readonly)

Returns the value of attribute source.



4
5
6
# File 'lib/minecraft-jsonapi/response.rb', line 4

def source
  @source
end