Class: NewDemoApiClient::Scale
- Inherits:
-
Object
- Object
- NewDemoApiClient::Scale
- Defined in:
- lib/test_sdk/types/scale.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#high ⇒ Float
readonly
High end of the scale.
-
#low ⇒ Float
readonly
Low end of the scale.
-
#metric ⇒ String
readonly
The metric whose scale is used to subset the benchmark data.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ NewDemoApiClient::Scale
Deserialize a JSON object to an instance of Scale.
-
.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.
Instance Method Summary collapse
- #initialize(metric:, low:, high:, additional_properties: nil) ⇒ NewDemoApiClient::Scale constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Scale to a JSON object.
Constructor Details
#initialize(metric:, low:, high:, additional_properties: nil) ⇒ NewDemoApiClient::Scale
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_properties ⇒ OpenStruct (readonly)
Returns 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 |
#high ⇒ Float (readonly)
Returns High end of the scale.
13 14 15 |
# File 'lib/test_sdk/types/scale.rb', line 13 def high @high end |
#low ⇒ Float (readonly)
Returns Low end of the scale.
11 12 13 |
# File 'lib/test_sdk/types/scale.rb', line 11 def low @low end |
#metric ⇒ String (readonly)
Returns 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
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.
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
56 57 58 |
# File 'lib/test_sdk/types/scale.rb', line 56 def to_json(*_args) @_field_set&.to_json end |