Class: StatsCloud::ParsedResponseHelper

Inherits:
Object
  • Object
show all
Includes:
JsonParser
Defined in:
lib/statscloud/helpers/cluster_client/parsed_response_helper.rb

Overview

This helper works to parse response from the server to convenient object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from JsonParser

#convert_to_pretty_json, #parse_json

Constructor Details

#initialize(response) ⇒ ParsedResponseHelper

Creates new helper object with parsed response body as json.

Parameters:

  • response (+RestClient::Response+)

    response from the cluster.



23
24
25
26
# File 'lib/statscloud/helpers/cluster_client/parsed_response_helper.rb', line 23

def initialize(response)
  @code = response&.code
  @body = parse_json(response.body, nil)
end

Instance Attribute Details

#bodyObject (readonly)

RestClient json-parsed response body.

Type: Hash



12
13
14
# File 'lib/statscloud/helpers/cluster_client/parsed_response_helper.rb', line 12

def body
  @body
end

#codeObject (readonly)

RestClient response code.

Type: Integer



17
18
19
# File 'lib/statscloud/helpers/cluster_client/parsed_response_helper.rb', line 17

def code
  @code
end