Class: Verizon::Situation

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

Overview

This represents the situation container describing the event and the reliability of the detection source.

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(information_quality = nil, event_type = nil) ⇒ Situation

Returns a new instance of Situation.



40
41
42
43
# File 'lib/verizon/models/situation.rb', line 40

def initialize(information_quality = nil, event_type = nil)
  @information_quality = information_quality
  @event_type = event_type
end

Instance Attribute Details

#event_typeEventType

The type of event including direct and sub cause.

Returns:



20
21
22
# File 'lib/verizon/models/situation.rb', line 20

def event_type
  @event_type
end

#information_qualityInteger

The quality or reliability level of the information provided by the ITS-S application of the originating ITS-S.

Returns:

  • (Integer)


16
17
18
# File 'lib/verizon/models/situation.rb', line 16

def information_quality
  @information_quality
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/verizon/models/situation.rb', line 46

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  information_quality =
    hash.key?('informationQuality') ? hash['informationQuality'] : nil
  event_type = EventType.from_hash(hash['eventType']) if hash['eventType']

  # Create object from extracted values.
  Situation.new(information_quality,
                event_type)
end

.namesObject

A mapping from model property names to API property names.



23
24
25
26
27
28
# File 'lib/verizon/models/situation.rb', line 23

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['information_quality'] = 'informationQuality'
  @_hash['event_type'] = 'eventType'
  @_hash
end

.nullablesObject

An array for nullable fields



36
37
38
# File 'lib/verizon/models/situation.rb', line 36

def self.nullables
  []
end

.optionalsObject

An array for optional fields



31
32
33
# File 'lib/verizon/models/situation.rb', line 31

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (Situation | Hash)

    value against the validation is performed.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/verizon/models/situation.rb', line 61

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.information_quality,
                            ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.event_type,
                              ->(val) { EventType.validate(val) },
                              is_model_hash: true)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['informationQuality'],
                          ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['eventType'],
                            ->(val) { EventType.validate(val) },
                            is_model_hash: true)
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



90
91
92
93
94
# File 'lib/verizon/models/situation.rb', line 90

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

#to_sObject

Provides a human-readable string representation of the object.



84
85
86
87
# File 'lib/verizon/models/situation.rb', line 84

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