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.
-
#msg_cnt ⇒ Integer
It is used to provide a sequence number within a stream of messages with the same DSRCmsgID (here RoadSideAlert) and from the same sender.
-
#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 = nil, msg_cnt = 0, 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 = nil, msg_cnt = 0, description = SKIP) ⇒ SaeAlert
Returns a new instance of SaeAlert.
53 54 55 56 57 |
# File 'lib/verizon/models/sae_alert.rb', line 53 def initialize(type_event = nil, msg_cnt = 0, description = SKIP) @msg_cnt = msg_cnt unless msg_cnt == 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.
29 30 31 |
# File 'lib/verizon/models/sae_alert.rb', line 29 def description @description end |
#msg_cnt ⇒ Integer
It is used to provide a sequence number within a stream of messages with the same DSRCmsgID (here RoadSideAlert) and from the same sender.
15 16 17 |
# File 'lib/verizon/models/sae_alert.rb', line 15 def msg_cnt @msg_cnt 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.
24 25 26 |
# File 'lib/verizon/models/sae_alert.rb', line 24 def type_event @type_event end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/verizon/models/sae_alert.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. type_event = hash.key?('typeEvent') ? hash['typeEvent'] : nil msg_cnt = hash['msgCnt'] ||= 0 description = hash.key?('description') ? hash['description'] : SKIP # Create object from extracted values. SaeAlert.new(type_event, msg_cnt, description) end |
.names ⇒ Object
A mapping from model property names to API property names.
32 33 34 35 36 37 38 |
# File 'lib/verizon/models/sae_alert.rb', line 32 def self.names @_hash = {} if @_hash.nil? @_hash['msg_cnt'] = 'msgCnt' @_hash['type_event'] = 'typeEvent' @_hash['description'] = 'description' @_hash end |
.nullables ⇒ Object
An array for nullable fields
49 50 51 |
# File 'lib/verizon/models/sae_alert.rb', line 49 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
41 42 43 44 45 46 |
# File 'lib/verizon/models/sae_alert.rb', line 41 def self.optionals %w[ msg_cnt description ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/verizon/models/sae_alert.rb', line 76 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.
96 97 98 99 100 |
# File 'lib/verizon/models/sae_alert.rb', line 96 def inspect class_name = self.class.name.split('::').last "<#{class_name} msg_cnt: #{@msg_cnt.inspect}, type_event: #{@type_event.inspect},"\ " description: #{@description.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
89 90 91 92 93 |
# File 'lib/verizon/models/sae_alert.rb', line 89 def to_s class_name = self.class.name.split('::').last "<#{class_name} msg_cnt: #{@msg_cnt}, type_event: #{@type_event}, description:"\ " #{@description}>" end |