Class: NewDemoApiClient::ScaleModel

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk/types/scale_model.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_data:, pred:, bands:, additional_properties: nil) ⇒ NewDemoApiClient::ScaleModel

Parameters:

  • raw_data (Array<Hash{String => Float}>)

    Raw data points used to generate the scaling model. Dictionary of the two metrics, x then y.

  • pred (Array<Hash{String => Float}>)

    Predicted center trend line of the scaling model. Dictioary of the two metrics, x then y.

  • bands (Array<NewDemoApiClient::BandResponse>)

    Bands representing the range of the scaling model.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



32
33
34
35
36
37
38
# File 'lib/test_sdk/types/scale_model.rb', line 32

def initialize(raw_data:, pred:, bands:, additional_properties: nil)
  @raw_data = raw_data
  @pred = pred
  @bands = bands
  @additional_properties = additional_properties
  @_field_set = { "raw_data": raw_data, "pred": pred, "bands": bands }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



18
19
20
# File 'lib/test_sdk/types/scale_model.rb', line 18

def additional_properties
  @additional_properties
end

#bandsArray<NewDemoApiClient::BandResponse> (readonly)

Returns Bands representing the range of the scaling model.

Returns:



16
17
18
# File 'lib/test_sdk/types/scale_model.rb', line 16

def bands
  @bands
end

#predArray<Hash{String => Float}> (readonly)

Returns Predicted center trend line of the scaling model. Dictioary of the two metrics, x then y.

Returns:

  • (Array<Hash{String => Float}>)

    Predicted center trend line of the scaling model. Dictioary of the two metrics, x then y.



14
15
16
# File 'lib/test_sdk/types/scale_model.rb', line 14

def pred
  @pred
end

#raw_dataArray<Hash{String => Float}> (readonly)

Returns Raw data points used to generate the scaling model. Dictionary of the two metrics, x then y.

Returns:

  • (Array<Hash{String => Float}>)

    Raw data points used to generate the scaling model. Dictionary of the two metrics, x then y.



11
12
13
# File 'lib/test_sdk/types/scale_model.rb', line 11

def raw_data
  @raw_data
end

Class Method Details

.from_json(json_object:) ⇒ NewDemoApiClient::ScaleModel

Deserialize a JSON object to an instance of ScaleModel

Parameters:

  • json_object (String)

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/test_sdk/types/scale_model.rb', line 44

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  raw_data = parsed_json["raw_data"]
  pred = parsed_json["pred"]
  bands = parsed_json["bands"]&.map do |item|
    item = item.to_json
    NewDemoApiClient::BandResponse.from_json(json_object: item)
  end
  new(
    raw_data: raw_data,
    pred: pred,
    bands: bands,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


74
75
76
77
78
# File 'lib/test_sdk/types/scale_model.rb', line 74

def self.validate_raw(obj:)
  obj.raw_data.is_a?(Array) != false || raise("Passed value for field obj.raw_data is not the expected type, validation failed.")
  obj.pred.is_a?(Array) != false || raise("Passed value for field obj.pred is not the expected type, validation failed.")
  obj.bands.is_a?(Array) != false || raise("Passed value for field obj.bands is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ScaleModel to a JSON object

Returns:

  • (String)


64
65
66
# File 'lib/test_sdk/types/scale_model.rb', line 64

def to_json(*_args)
  @_field_set&.to_json
end