Class: Verizon::Header
- Defined in:
- lib/verizon/models/header.rb
Overview
The header of the DENM PDU.
Instance Attribute Summary collapse
-
#message_id ⇒ MessageIdEnum
The type of ITIS message (typically 1 for DENM).
-
#protocol_version ⇒ ProtocolVersionEnum
The protocol version of the DENM.
-
#station_id ⇒ Integer
The station identifier of the ITS-S.
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(protocol_version = nil, message_id = nil, station_id = nil) ⇒ Header
constructor
A new instance of Header.
-
#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(protocol_version = nil, message_id = nil, station_id = nil) ⇒ Header
Returns a new instance of Header.
43 44 45 46 47 |
# File 'lib/verizon/models/header.rb', line 43 def initialize(protocol_version = nil, = nil, station_id = nil) @protocol_version = protocol_version @message_id = @station_id = station_id end |
Instance Attribute Details
#message_id ⇒ MessageIdEnum
The type of ITIS message (typically 1 for DENM).
18 19 20 |
# File 'lib/verizon/models/header.rb', line 18 def @message_id end |
#protocol_version ⇒ ProtocolVersionEnum
The protocol version of the DENM.
14 15 16 |
# File 'lib/verizon/models/header.rb', line 14 def protocol_version @protocol_version end |
#station_id ⇒ Integer
The station identifier of the ITS-S.
22 23 24 |
# File 'lib/verizon/models/header.rb', line 22 def station_id @station_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/verizon/models/header.rb', line 50 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. protocol_version = hash.key?('protocolVersion') ? hash['protocolVersion'] : nil = hash.key?('messageId') ? hash['messageId'] : nil station_id = hash.key?('stationId') ? hash['stationId'] : nil # Create object from extracted values. Header.new(protocol_version, , station_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 |
# File 'lib/verizon/models/header.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['protocol_version'] = 'protocolVersion' @_hash['message_id'] = 'messageId' @_hash['station_id'] = 'stationId' @_hash end |
.nullables ⇒ Object
An array for nullable fields
39 40 41 |
# File 'lib/verizon/models/header.rb', line 39 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
34 35 36 |
# File 'lib/verizon/models/header.rb', line 34 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/verizon/models/header.rb', line 67 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.protocol_version, ->(val) { ProtocolVersionEnum.validate(val) }) and APIHelper.valid_type?(value., ->(val) { MessageIdEnum.validate(val) }) and APIHelper.valid_type?(value.station_id, ->(val) { val.instance_of? Integer }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['protocolVersion'], ->(val) { ProtocolVersionEnum.validate(val) }) and APIHelper.valid_type?(value['messageId'], ->(val) { MessageIdEnum.validate(val) }) and APIHelper.valid_type?(value['stationId'], ->(val) { val.instance_of? Integer }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
99 100 101 102 103 |
# File 'lib/verizon/models/header.rb', line 99 def inspect class_name = self.class.name.split('::').last "<#{class_name} protocol_version: #{@protocol_version.inspect}, message_id:"\ " #{@message_id.inspect}, station_id: #{@station_id.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
92 93 94 95 96 |
# File 'lib/verizon/models/header.rb', line 92 def to_s class_name = self.class.name.split('::').last "<#{class_name} protocol_version: #{@protocol_version}, message_id: #{@message_id},"\ " station_id: #{@station_id}>" end |