lib/megar/connection.rb
def parse_json_response(body)
    begin
      response_data = JSON.parse(body)
      response_data = response_data.first if response_data.is_a?(Array)
    rescue => e
      raise Megar::MegaRequestError.new(body.to_i) if body =~ /^[-\d]+$/
      raise Megar::BadApiResponseError.new(e)
    end
    raise Megar::MegaRequestError.new(response_data) if response_data.is_a?(Fixnum)
    response_data
  end
# Returns the first response as JSON from response +body+, raising Mega error if present.
# Note: expects and currently only handles a single response in the data
Returns the first response as JSON from response +body+, raising Mega error if present.
Note: expects and currently only handles a single response in the data
Returns the first response as JSON from response + body + raising Mega error if present . Note : expects and currently only handles a single response in the data
def parse_json_response(body)
    begin
      response_data = JSON.parse(body)
      response_data = response_data.first if response_data.is_a?(Array)
    rescue => e
      raise Megar::MegaRequestError.new(body.to_i) if body =~ /^[-\d]+$/
      raise Megar::BadApiResponseError.new(e)
    end
    raise Megar::MegaRequestError.new(response_data) if response_data.is_a?(Fixnum)
    response_data
  end
def parse_json_response ( body ) begin response_data = JSON . parse ( body ) response_data = response_data . first if response_data . is_a? ( Array ) rescue => e raise Megar :: MegaRequestError . new ( body . to_i ) if body =~ / ^[- \d ]+$ / raise Megar :: BadApiResponseError . new ( e ) end raise Megar :: MegaRequestError . new ( response_data ) if response_data . is_a? ( Fixnum ) response_data end
Returns the first response as JSON from response +body+, raising Mega error if present.
Returns the first response as JSON from response + body + raising Mega error if present .
body