Class: Samsara::Types::HosCycle

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/types/hos_cycle.rb

Overview

Remaining durations and start time for the HOS driving cycle.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cycle_remaining_duration_ms: OMIT, cycle_started_at_time: OMIT, cycle_tomorrow_duration_ms: OMIT, additional_properties: nil) ⇒ Samsara::Types::HosCycle

Parameters:

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



38
39
40
41
42
43
44
45
46
# File 'lib/samsara_api/types/hos_cycle.rb', line 38

def initialize(cycle_remaining_duration_ms: OMIT, cycle_started_at_time: OMIT, cycle_tomorrow_duration_ms: OMIT, additional_properties: nil)
  @cycle_remaining_duration_ms = cycle_remaining_duration_ms if cycle_remaining_duration_ms != OMIT
  @cycle_started_at_time = cycle_started_at_time if cycle_started_at_time != OMIT
  @cycle_tomorrow_duration_ms = cycle_tomorrow_duration_ms if cycle_tomorrow_duration_ms != OMIT
  @additional_properties = additional_properties
  @_field_set = { "cycleRemainingDurationMs": cycle_remaining_duration_ms, "cycleStartedAtTime": cycle_started_at_time, "cycleTomorrowDurationMs": cycle_tomorrow_duration_ms }.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



21
22
23
# File 'lib/samsara_api/types/hos_cycle.rb', line 21

def additional_properties
  @additional_properties
end

#cycle_remaining_duration_msObject (readonly)

days.



13
14
15
# File 'lib/samsara_api/types/hos_cycle.rb', line 13

def cycle_remaining_duration_ms
  @cycle_remaining_duration_ms
end

#cycle_started_at_timeString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/samsara_api/types/hos_cycle.rb', line 15

def cycle_started_at_time
  @cycle_started_at_time
end

#cycle_tomorrow_duration_msObject (readonly)

60/70-hour limit in 7/8 days rule.



19
20
21
# File 'lib/samsara_api/types/hos_cycle.rb', line 19

def cycle_tomorrow_duration_ms
  @cycle_tomorrow_duration_ms
end

Class Method Details

.from_json(json_object:) ⇒ Samsara::Types::HosCycle

Parameters:

  • json_object (String)

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/samsara_api/types/hos_cycle.rb', line 51

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  cycle_remaining_duration_ms = parsed_json["cycleRemainingDurationMs"]
  cycle_started_at_time = parsed_json["cycleStartedAtTime"]
  cycle_tomorrow_duration_ms = parsed_json["cycleTomorrowDurationMs"]
  new(
    cycle_remaining_duration_ms: cycle_remaining_duration_ms,
    cycle_started_at_time: cycle_started_at_time,
    cycle_tomorrow_duration_ms: cycle_tomorrow_duration_ms,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


76
77
78
79
80
# File 'lib/samsara_api/types/hos_cycle.rb', line 76

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

Instance Method Details

#to_jsonString

Returns:

  • (String)


67
68
69
# File 'lib/samsara_api/types/hos_cycle.rb', line 67

def to_json
  @_field_set&.to_json
end