Class: Ksql::Connection::Response

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

Constant Summary collapse

STATUS_KEY =
':status'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body:, headers:) ⇒ Response

Returns a new instance of Response.



10
11
12
13
# File 'lib/ksql/connection/response.rb', line 10

def initialize(body:, headers:)
  @body = JSON.parse(body)
  @headers = headers
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/ksql/connection/response.rb', line 6

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



6
7
8
# File 'lib/ksql/connection/response.rb', line 6

def headers
  @headers
end

Instance Method Details

#error?Boolean

Check whether or not a Request has returned an Error

Returns:

  • (Boolean)

    True if error



20
21
22
# File 'lib/ksql/connection/response.rb', line 20

def error?
  !headers[STATUS_KEY].to_s.match?(/20[01]/)
end