Class: NewDemoApiClient::ColumnMetadata

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, friendly_name:, unit:, scaling:, reverse:, cutoff: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::ColumnMetadata

Parameters:

  • name (String)

    The name of the column.

  • friendly_name (String)

    The friendly displayable name of the column.

  • unit (NewDemoApiClient::Unit)

    The unit of the category.

  • scaling (NewDemoApiClient::Scaling)

    The scaling type of the column. Geometric indicates exponential changes are expected, while arithmetic indicates linear changes.

  • reverse (Boolean)

    Whether the column is expected to be higher or lower for better performance. False means higher is better, True means lower is better.

  • cutoff (Float) (defaults to: OMIT)

    The suggested cutoff value for the column. This is a guideline for when the absolute value of the column is considered saturated.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(name:, friendly_name:, unit:, scaling:, reverse:, cutoff: OMIT, additional_properties: nil)
  @name = name
  @friendly_name = friendly_name
  @unit = unit
  @scaling = scaling
  @reverse = reverse
  @cutoff = cutoff if cutoff != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "name": name,
    "friendly_name": friendly_name,
    "unit": unit,
    "scaling": scaling,
    "reverse": reverse,
    "cutoff": cutoff
  }.reject do |_k, v|
    v == OMIT
  end
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



26
27
28
# File 'lib/test_sdk/types/column_metadata.rb', line 26

def additional_properties
  @additional_properties
end

#cutoffFloat (readonly)

Returns The suggested cutoff value for the column. This is a guideline for when the absolute value of the column is considered saturated.

Returns:

  • (Float)

    The suggested cutoff value for the column. This is a guideline for when the absolute value of the column is considered saturated.



24
25
26
# File 'lib/test_sdk/types/column_metadata.rb', line 24

def cutoff
  @cutoff
end

#friendly_nameString (readonly)

Returns The friendly displayable name of the column.

Returns:

  • (String)

    The friendly displayable name of the column.



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

def friendly_name
  @friendly_name
end

#nameString (readonly)

Returns The name of the column.

Returns:

  • (String)

    The name of the column.



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

def name
  @name
end

#reverseBoolean (readonly)

Returns Whether the column is expected to be higher or lower for better performance. False means higher is better, True means lower is better.

Returns:

  • (Boolean)

    Whether the column is expected to be higher or lower for better performance. False means higher is better, True means lower is better.



21
22
23
# File 'lib/test_sdk/types/column_metadata.rb', line 21

def reverse
  @reverse
end

#scalingNewDemoApiClient::Scaling (readonly)

Returns The scaling type of the column. Geometric indicates exponential changes are expected, while arithmetic indicates linear changes.

Returns:

  • (NewDemoApiClient::Scaling)

    The scaling type of the column. Geometric indicates exponential changes are expected, while arithmetic indicates linear changes.



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

def scaling
  @scaling
end

#unitNewDemoApiClient::Unit (readonly)

Returns The unit of the category.

Returns:



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

def unit
  @unit
end

Class Method Details

.from_json(json_object:) ⇒ NewDemoApiClient::ColumnMetadata

Deserialize a JSON object to an instance of ColumnMetadata

Parameters:

  • json_object (String)

Returns:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/test_sdk/types/column_metadata.rb', line 68

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  name = parsed_json["name"]
  friendly_name = parsed_json["friendly_name"]
  unit = parsed_json["unit"]
  scaling = parsed_json["scaling"]
  reverse = parsed_json["reverse"]
  cutoff = parsed_json["cutoff"]
  new(
    name: name,
    friendly_name: friendly_name,
    unit: unit,
    scaling: scaling,
    reverse: reverse,
    cutoff: cutoff,
    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)


101
102
103
104
105
106
107
108
# File 'lib/test_sdk/types/column_metadata.rb', line 101

def self.validate_raw(obj:)
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.friendly_name.is_a?(String) != false || raise("Passed value for field obj.friendly_name is not the expected type, validation failed.")
  obj.unit.is_a?(NewDemoApiClient::Unit) != false || raise("Passed value for field obj.unit is not the expected type, validation failed.")
  obj.scaling.is_a?(NewDemoApiClient::Scaling) != false || raise("Passed value for field obj.scaling is not the expected type, validation failed.")
  obj.reverse.is_a?(Boolean) != false || raise("Passed value for field obj.reverse is not the expected type, validation failed.")
  obj.cutoff&.is_a?(Float) != false || raise("Passed value for field obj.cutoff is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ColumnMetadata to a JSON object

Returns:

  • (String)


91
92
93
# File 'lib/test_sdk/types/column_metadata.rb', line 91

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