Sha256: 8427f9ffaba8b145724b8330d5232f9bda3018427f41aa5cf855fdeb8c356311

Contents?: true

Size: 492 Bytes

Versions: 1

Compression:

Stored size: 492 Bytes

Contents

# frozen_string_literal: true

module Tinybird
  class Response
    attr_reader :status, :headers, :body, :message

    def initialize(response)
      @status = response.code.to_i
      @headers = response.to_hash
      @message = response.message
      @body = begin
        JSON.parse(response.body)
      rescue JSON::ParserError
        response.body
      end
    end

    def inspect
      "#<#{self.class}:0x#{object_id.to_s(16)} #{status} #{message} readbody=true>"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tinybird-0.1.1 lib/tinybird/response.rb