class Minecraft::JSONAPIv2::Response

Attributes

raw_response[R]
response[R]

Public Class Methods

new(data) click to toggle source
# File lib/minecraft_jsonapiv2/response.rb, line 5
def initialize(data)
  @response = {}
  data = JSON.parse(data)
  @raw_response = data
  if data.count == 1
    data = data[0]
  end
  if data.is_a? Array
    data.each do |d|
      @response[d['source'].gsub(/\./, '_')] = d['success']
    end
    @response = Mash.new @response.rubyify_keys!
  else
    @response = data['success']
    @response = Mash.new @response.rubyify_keys! if @response.is_a? Hash
  end
  @response
end