Class: Verizon::SaeAlert

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/sae_alert.rb

Overview

SaeAlert Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(type_event:, description: SKIP) ⇒ SaeAlert

Returns a new instance of SaeAlert.



46
47
48
49
# File 'lib/verizon/models/sae_alert.rb', line 46

def initialize(type_event:, description: SKIP)
  @type_event = type_event
  @description = description unless description == SKIP
end

Instance Attribute Details

#descriptionArray[Integer]

ITIS code set entries to further describe the event, give advice, or any other ITIS codes related to the event/danger/hazard.

Returns:

  • (Array[Integer])


24
25
26
# File 'lib/verizon/models/sae_alert.rb', line 24

def description
  @description
end

#type_eventInteger

The ITIS Code that describes the alert/danger/hazard. All ITS standards use the same types here to explain the type of the alert/danger/hazard involved. The complete set of ITIS codes can be found in Volume Two of the SAE J2540 standard. This is a set of over 1000 items which are used to encode common events and list items in ITS.

Returns:

  • (Integer)


19
20
21
# File 'lib/verizon/models/sae_alert.rb', line 19

def type_event
  @type_event
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/verizon/models/sae_alert.rb', line 52

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  type_event = hash.key?('typeEvent') ? hash['typeEvent'] : nil
  description = hash.key?('description') ? hash['description'] : SKIP

  # Create object from extracted values.
  SaeAlert.new(type_event: type_event,
               description: description)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
# File 'lib/verizon/models/sae_alert.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['type_event'] = 'typeEvent'
  @_hash['description'] = 'description'
  @_hash
end

.nullablesObject

An array for nullable fields



42
43
44
# File 'lib/verizon/models/sae_alert.rb', line 42

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
38
39
# File 'lib/verizon/models/sae_alert.rb', line 35

def self.optionals
  %w[
    description
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (SaeAlert | Hash)

    value against the validation is performed.



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/verizon/models/sae_alert.rb', line 66

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.type_event,
                                 ->(val) { val.instance_of? Integer })
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['typeEvent'],
                        ->(val) { val.instance_of? Integer })
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



85
86
87
88
# File 'lib/verizon/models/sae_alert.rb', line 85

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} type_event: #{@type_event.inspect}, description: #{@description.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



79
80
81
82
# File 'lib/verizon/models/sae_alert.rb', line 79

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} type_event: #{@type_event}, description: #{@description}>"
end