Class: Verizon::SaeInfo

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

Overview

SaeInfo 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(data_frames = nil, msg_cnt = 0, time_stamp = SKIP, packet_id = SKIP, url_b = SKIP) ⇒ SaeInfo

Returns a new instance of SaeInfo.



66
67
68
69
70
71
72
73
# File 'lib/verizon/models/sae_info.rb', line 66

def initialize(data_frames = nil, msg_cnt = 0, time_stamp = SKIP,
               packet_id = SKIP, url_b = SKIP)
  @msg_cnt = msg_cnt unless msg_cnt == SKIP
  @time_stamp = time_stamp unless time_stamp == SKIP
  @packet_id = packet_id unless packet_id == SKIP
  @url_b = url_b unless url_b == SKIP
  @data_frames = data_frames
end

Instance Attribute Details

#data_framesArray[DataFrame]

List of data frames.

Returns:



38
39
40
# File 'lib/verizon/models/sae_info.rb', line 38

def data_frames
  @data_frames
end

#msg_cntInteger

It is used to provide a sequence number within a stream of messages with the same DSRCmsgID (here RoadSideAlert) and from the same sender.

Returns:

  • (Integer)


15
16
17
# File 'lib/verizon/models/sae_info.rb', line 15

def msg_cnt
  @msg_cnt
end

#packet_idString

Provides a relatively unique value which can be used to connect to (link to) other supporting messages in other formats. The value is described as a 18-character hexadecimal string.

Returns:

  • (String)


27
28
29
# File 'lib/verizon/models/sae_info.rb', line 27

def packet_id
  @packet_id
end

#time_stampInteger

The number of elapsed minutes of the current year in the time system being used (typically UTC time). – the value 527040 shall be used for invalid

Returns:

  • (Integer)


21
22
23
# File 'lib/verizon/models/sae_info.rb', line 21

def time_stamp
  @time_stamp
end

#url_bString

A valid internet style URI/URL in the form of a text string which will form the base of a compound string which, when combined with the URL-short data element, will link to the designated resource.

Returns:

  • (String)


34
35
36
# File 'lib/verizon/models/sae_info.rb', line 34

def url_b
  @url_b
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/verizon/models/sae_info.rb', line 76

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  data_frames = nil
  unless hash['dataFrames'].nil?
    data_frames = []
    hash['dataFrames'].each do |structure|
      data_frames << (DataFrame.from_hash(structure) if structure)
    end
  end

  data_frames = nil unless hash.key?('dataFrames')
  msg_cnt = hash['msgCnt'] ||= 0
  time_stamp = hash.key?('timeStamp') ? hash['timeStamp'] : SKIP
  packet_id = hash.key?('packetID') ? hash['packetID'] : SKIP
  url_b = hash.key?('urlB') ? hash['urlB'] : SKIP

  # Create object from extracted values.
  SaeInfo.new(data_frames,
              msg_cnt,
              time_stamp,
              packet_id,
              url_b)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
# File 'lib/verizon/models/sae_info.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['msg_cnt'] = 'msgCnt'
  @_hash['time_stamp'] = 'timeStamp'
  @_hash['packet_id'] = 'packetID'
  @_hash['url_b'] = 'urlB'
  @_hash['data_frames'] = 'dataFrames'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
# File 'lib/verizon/models/sae_info.rb', line 62

def self.nullables
  []
end

.optionalsObject

An array for optional fields



52
53
54
55
56
57
58
59
# File 'lib/verizon/models/sae_info.rb', line 52

def self.optionals
  %w[
    msg_cnt
    time_stamp
    packet_id
    url_b
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (SaeInfo | Hash)

    value against the validation is performed.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/verizon/models/sae_info.rb', line 105

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.data_frames,
                                 ->(val) { DataFrame.validate(val) },
                                 is_model_hash: true,
                                 is_inner_model_hash: true)
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['dataFrames'],
                        ->(val) { DataFrame.validate(val) },
                        is_model_hash: true,
                        is_inner_model_hash: true)
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



129
130
131
132
133
134
# File 'lib/verizon/models/sae_info.rb', line 129

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} msg_cnt: #{@msg_cnt.inspect}, time_stamp: #{@time_stamp.inspect},"\
  " packet_id: #{@packet_id.inspect}, url_b: #{@url_b.inspect}, data_frames:"\
  " #{@data_frames.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



122
123
124
125
126
# File 'lib/verizon/models/sae_info.rb', line 122

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} msg_cnt: #{@msg_cnt}, time_stamp: #{@time_stamp}, packet_id: #{@packet_id},"\
  " url_b: #{@url_b}, data_frames: #{@data_frames}>"
end