Class: Minecraft::JSONAPIv2::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/minecraft_jsonapiv2/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/minecraft_jsonapiv2/response.rb', line 5

def initialize(data)
    @response = {}
    data = JSON.parse(data)
    @raw_response = data
    if data.is_a? Array
        data.each do |d|
            @response[d['source'].gsub(/\./, '_')] = d['success']
        end
    else
        @response[data['source'].gsub(/\./, '_')] = data['success']
    end
    @response.rubyify_keys!
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



4
5
6
# File 'lib/minecraft_jsonapiv2/response.rb', line 4

def raw_response
  @raw_response
end

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/minecraft_jsonapiv2/response.rb', line 4

def response
  @response
end