Class: Verizon::SaeAlert
- Defined in:
- lib/verizon/models/sae_alert.rb
Overview
SaeAlert Model.
Instance Attribute Summary collapse
-
#description ⇒ Array[Integer]
ITIS code set entries to further describe the event, give advice, or any other ITIS codes related to the event/danger/hazard.
-
#type_event ⇒ Integer
The ITIS Code that describes the alert/danger/hazard.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(type_event:, description: SKIP) ⇒ SaeAlert
constructor
A new instance of SaeAlert.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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
#description ⇒ Array[Integer]
ITIS code set entries to further describe the event, give advice, or any other ITIS codes related to the event/danger/hazard.
24 25 26 |
# File 'lib/verizon/models/sae_alert.rb', line 24 def description @description end |
#type_event ⇒ Integer
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.
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 |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
42 43 44 |
# File 'lib/verizon/models/sae_alert.rb', line 42 def self.nullables [] end |
.optionals ⇒ Object
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.
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
#inspect ⇒ Object
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_s ⇒ Object
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 |