Class: TrophyApiClient::PointsRange

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/points_range.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from: OMIT, to: OMIT, users: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsRange

Parameters:

  • from (Float) (defaults to: OMIT)

    The start of the points range. Inclusive.

  • to (Float) (defaults to: OMIT)

    The end of the points range. Inclusive.

  • users (Float) (defaults to: OMIT)

    The number of users in this points range.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



27
28
29
30
31
32
33
34
35
# File 'lib/trophy_api_client/types/points_range.rb', line 27

def initialize(from: OMIT, to: OMIT, users: OMIT, additional_properties: nil)
  @from = from if from != OMIT
  @to = to if to != OMIT
  @users = users if users != OMIT
  @additional_properties = additional_properties
  @_field_set = { "from": from, "to": to, "users": users }.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



15
16
17
# File 'lib/trophy_api_client/types/points_range.rb', line 15

def additional_properties
  @additional_properties
end

#fromFloat (readonly)

Returns The start of the points range. Inclusive.

Returns:

  • (Float)

    The start of the points range. Inclusive.



9
10
11
# File 'lib/trophy_api_client/types/points_range.rb', line 9

def from
  @from
end

#toFloat (readonly)

Returns The end of the points range. Inclusive.

Returns:

  • (Float)

    The end of the points range. Inclusive.



11
12
13
# File 'lib/trophy_api_client/types/points_range.rb', line 11

def to
  @to
end

#usersFloat (readonly)

Returns The number of users in this points range.

Returns:

  • (Float)

    The number of users in this points range.



13
14
15
# File 'lib/trophy_api_client/types/points_range.rb', line 13

def users
  @users
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::PointsRange

Deserialize a JSON object to an instance of PointsRange

Parameters:

  • json_object (String)

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/trophy_api_client/types/points_range.rb', line 41

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


68
69
70
71
72
# File 'lib/trophy_api_client/types/points_range.rb', line 68

def self.validate_raw(obj:)
  obj.from&.is_a?(Float) != false || raise("Passed value for field obj.from is not the expected type, validation failed.")
  obj.to&.is_a?(Float) != false || raise("Passed value for field obj.to is not the expected type, validation failed.")
  obj.users&.is_a?(Float) != false || raise("Passed value for field obj.users is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PointsRange to a JSON object

Returns:

  • (String)


58
59
60
# File 'lib/trophy_api_client/types/points_range.rb', line 58

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