Class: NewDemoApiClient::Scale

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metric:, low:, high:, additional_properties: nil) ⇒ NewDemoApiClient::Scale

Parameters:

  • metric (String)

    The metric whose scale is used to subset the benchmark data.

  • low (Float)

    Low end of the scale.

  • high (Float)

    High end of the scale.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



27
28
29
30
31
32
33
# File 'lib/test_sdk/types/scale.rb', line 27

def initialize(metric:, low:, high:, additional_properties: nil)
  @metric = metric
  @low = low
  @high = high
  @additional_properties = additional_properties
  @_field_set = { "metric": metric, "low": low, "high": high }
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



15
16
17
# File 'lib/test_sdk/types/scale.rb', line 15

def additional_properties
  @additional_properties
end

#highFloat (readonly)

Returns High end of the scale.

Returns:

  • (Float)

    High end of the scale.



13
14
15
# File 'lib/test_sdk/types/scale.rb', line 13

def high
  @high
end

#lowFloat (readonly)

Returns Low end of the scale.

Returns:

  • (Float)

    Low end of the scale.



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

def low
  @low
end

#metricString (readonly)

Returns The metric whose scale is used to subset the benchmark data.

Returns:

  • (String)

    The metric whose scale is used to subset the benchmark data.



9
10
11
# File 'lib/test_sdk/types/scale.rb', line 9

def metric
  @metric
end

Class Method Details

.from_json(json_object:) ⇒ NewDemoApiClient::Scale

Deserialize a JSON object to an instance of Scale

Parameters:

  • json_object (String)

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/test_sdk/types/scale.rb', line 39

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  metric = parsed_json["metric"]
  low = parsed_json["low"]
  high = parsed_json["high"]
  new(
    metric: metric,
    low: low,
    high: high,
    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)


66
67
68
69
70
# File 'lib/test_sdk/types/scale.rb', line 66

def self.validate_raw(obj:)
  obj.metric.is_a?(String) != false || raise("Passed value for field obj.metric is not the expected type, validation failed.")
  obj.low.is_a?(Float) != false || raise("Passed value for field obj.low is not the expected type, validation failed.")
  obj.high.is_a?(Float) != false || raise("Passed value for field obj.high is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Scale to a JSON object

Returns:

  • (String)


56
57
58
# File 'lib/test_sdk/types/scale.rb', line 56

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